PDA

View Full Version : Error "Update or CancelUpdate without AddNew or Edit"



gsanghvi20
07-31-2008, 01:31 PM
Hey guys,

I have a form which has a many text boxes and a combobox. One of the text boxes and the combobox form the composite PK. The value of the PK text box is taken from another from. And based on that I select the combobox values.

eg: I have the first name of a person in one txt box in one form, and the last name in the form of a combobx in another form.

Form 1:
First Name: John

Form 2:
First Name: John (disabled>value taken from Form 1)
Last Name: Drop down of available last names with John as a first name.
...
...
List of the other attributes in the table.

Now I want that when I select a Last Name it gives me all the attributes in the respective text boxes. I have done all the needful according to me. But the data in the respective text boxes on selecting the Last Name does not give me anything. When I go ahead and try to update any field it gives me an error: "Update or CancelUpdate without AddNew or Edit".

Please tell me what to do.:help

Thanks,
gsanghvi20

ibgreat
07-31-2008, 02:48 PM
just curious, why are you pulling only the first name from a different form. I would think cascading combo boxes would likely be more effective. Posting the code would be helpful.

gsanghvi20
08-01-2008, 08:40 AM
I guess I gave a misleading eg. I have a field called Manager Name and every Manager has one or many Funds. The Manager name is pulled from the Manager table which is the PK in that table and the FK in the Fund table. That is the reason I have 2 forms for them as there is too much information to be put in one form. So in 1 form we enter all the Manager info and on clicking a button "Update Fund" it takes to a page which has the manager Name displayed in the text box automatically (disabled) and then a drop down for the Funds under that Manager. I hope I am making sense.

CreganTur
08-01-2008, 09:08 AM
So in 1 form we enter all the Manager info and on clicking a button "Update Fund" it takes to a page which has the manager Name displayed in the text box automatically (disabled) and then a drop down for the Funds under that Manager

For the On Load event of your Form you can set the Row Source of your combobox using VBA. Something like:
Me.cboName = "SELECT * FROM tblName WHERE tblName.ManagerName = '" & Me.txtManagerName & "'"
where txtManagerName is the name of the textbox that contains the manager's name from the previous Form, and cboName is the name of the combobox you want to work with.

For the combobox's properties set the Row Source Type to 'Table/Query', but leave the Row Source blank.

HTH:thumb

gsanghvi20
08-06-2008, 06:24 AM
I have done that part. Now I want that when I select a Fund Name it gives me all the attributes in the respective text boxes. I have done all the needful according to me. But the data in the respective text boxes on selecting the Fund Name does not give me anything. When I go ahead and try to update any field it gives me an error: "Update or CancelUpdate without AddNew or Edit".

Please :help

Thanks,
gsanghvi20

CreganTur
08-06-2008, 07:58 AM
If I understand your problem correctly, then I am guessing that the manager name textbox and the fund combobox are on the form that contains the 'attribute' textboxes.

I would suggest that you put the manager name and fund name comboboxes on the same form, separate from all of the attribute textboxes you want filled in. Then, I would use the Where Condition that is a part of DoCmd.OpenForm, and include the values of the Manager and Fund name comboboxes as part of the Where Condition. This will open your attribute form to the record you want to view.

HTH

gsanghvi20
08-06-2008, 08:06 AM
Instead of putting the where condition in the DoCmd.OpenForm, I made a combo box using the 3rd option (selects the data based on the value of the combo box). But it still doesnt work :(
Also I do have Manager name and all its attributes on one form and the Manager name and Fund name and all the fund attributes in the 2nd form.