Hello everyone,
I have a database with three forms which correspond to three tables. However, two of these forms need to add data to another table, as well as their 'main' table, when a user chooses to do so. I've accomplished this by following the suggestions of a few different forum members - it works by using a command button to kick off an append query which adds all records which meet a given criteria - a "yes" value in a check box in a particular field.
But I've run into two problems. The first I was able to correct after another idea from the forum. The query tried to add ALL checked-off records, even ones which it had already added. It would return an error message, saying, essentially, "only new records have been added, not the duplicates." I used
to disable the error message before running the query, then set it to
again afterwards.
So - here's the new problem: sometimes, the users are going to want to use the form to update a given record which already exists in the table. But at this point, if they change a record, the changes are only recorded in the form's main table; they aren't recorded in the other table because the query overlooks them. If the primary field is unchanged, the query apparently treats them as duplicates, and if the primary field is updated, the secondary table only shows updates in that field, but none of the others.
I hoped to get around this simply by enforcing referential integrity and cascading updates - but that won't work, as apparently that's only possible in fields with a unique index, and most of the fields I'm working with won't have one.
Does anyone have an idea of how I can work this out to be able to use the form to update a record that's already been added, and to have the changes show up in both tables instead of only the form's 'main' table?
Thanks for any help anyone can offer.
- Spherey
I have a database with three forms which correspond to three tables. However, two of these forms need to add data to another table, as well as their 'main' table, when a user chooses to do so. I've accomplished this by following the suggestions of a few different forum members - it works by using a command button to kick off an append query which adds all records which meet a given criteria - a "yes" value in a check box in a particular field.
But I've run into two problems. The first I was able to correct after another idea from the forum. The query tried to add ALL checked-off records, even ones which it had already added. It would return an error message, saying, essentially, "only new records have been added, not the duplicates." I used
Code:
DoCmd.SetWarnings False
Code:
True
So - here's the new problem: sometimes, the users are going to want to use the form to update a given record which already exists in the table. But at this point, if they change a record, the changes are only recorded in the form's main table; they aren't recorded in the other table because the query overlooks them. If the primary field is unchanged, the query apparently treats them as duplicates, and if the primary field is updated, the secondary table only shows updates in that field, but none of the others.
I hoped to get around this simply by enforcing referential integrity and cascading updates - but that won't work, as apparently that's only possible in fields with a unique index, and most of the fields I'm working with won't have one.
Does anyone have an idea of how I can work this out to be able to use the form to update a record that's already been added, and to have the changes show up in both tables instead of only the form's 'main' table?
Thanks for any help anyone can offer.
- Spherey