View Full Version : subform change


karmawangdi
05-21-2001, 09:42 PM
I have a data entry form that contains a subform. The main form contains the employee ID (a combo box) and the subform is supposed to contain the items issued to them. The table for the main form is based on an employee table and that of the subform is based on the item issed table. These tables bear a one-to-many relationship, respectively. When the form is run, as expected the form and subform show up with appropriate data. However when I change the employee ID in the main form by clicking on a different employee ID in the combo box an automatic change in the subform data does not happen and consequently when I close the form I get an error message.

What should be done so that when a different employee ID is clicked on the combo box the data in the subform chage accordingly. By the way the main form and subform are designed usign the wizard in Access2000

charityg
05-22-2001, 11:00 AM
in the afterupdate event of the combobox, requery the subform with:
subformname.requery

Pat Hartman
05-22-2001, 04:51 PM
You can't use the same combobox to search for new records as you use to enter the key value. If you really want to change the foreign key of the subform's records you need to specify enforce referential integrity in the relationship between them set up in the relationship window. You also need to specify cascade updates. I don't get the impression that this is your intention though so make a separate combobox and check the find new records option in the wizard screen.