Hello everyone -
Yesterday we generated a long, long thread
- thread702-587534 - about the best way to enter data from one form into two tables simultaneously when a user elected to do so. After a lot of helpful suggestions which for the most part didn't work for some reason, one of the forum members suggested that I not bother with the visual basic coding and opt for a more straightforward append query. So, I set that up, and guess what? It actually works! But, it's pretty convoluted, and I get an error message every time I run it telling me that it isn't going to add any of the records which are duplicates. And that's great - I don't want duplicate records. So, I have two questions:
1.) Can I specify in the append query that I only want to add those records which are new? As in, those records which have not ALREADY been added to the table? That way, the query won't try to add them anyway and return a message saying that it can't duplicate the records and has only added the newer ones.
2.) This is how I have it set up right now - and like I said, it does work, although I get the error message which is sure to alarm the end users. I'll describe how it works, and if anyone can see an immediately obvious way to make this less circuitous and more elegant, by all means clue me in.
Big thanks to everyone who's taken time to help me work this stuff out. I, too, am finding out that the more versed I become in Access, the more I come across things that still seem new or puzzling.
So: The situation is, I have a form which of course sends data to its underlying table; but if a user chooses, I want some of the data to also be sent to a second table, whose relevant field names match the primary table. How I've set this up is with an append query - if a box is check in the primary table (and thus in the query), the fields are appended to the second table. In the form, I've included the box to check, and a command button underneath it to run the append query. So the user would check the box, signifying that this data is to be sent to the second table, and then click the button, signifying 'do it now,' essentially. And, because there are other records which have previously been added to the form, the query is at this point trying to add them again, realizing that it can't (because doing so would duplicate a value in a primary key) and returning an error message to the tune of "none of the duplicate records were added."
The biggest thing that would help me is learning a way to tell the query that it's only supposed to add fields which are NOT duplicates, i.e., that are new.
Any advice?
Thanks a lot,
Spherey
Yesterday we generated a long, long thread
- thread702-587534 - about the best way to enter data from one form into two tables simultaneously when a user elected to do so. After a lot of helpful suggestions which for the most part didn't work for some reason, one of the forum members suggested that I not bother with the visual basic coding and opt for a more straightforward append query. So, I set that up, and guess what? It actually works! But, it's pretty convoluted, and I get an error message every time I run it telling me that it isn't going to add any of the records which are duplicates. And that's great - I don't want duplicate records. So, I have two questions:
1.) Can I specify in the append query that I only want to add those records which are new? As in, those records which have not ALREADY been added to the table? That way, the query won't try to add them anyway and return a message saying that it can't duplicate the records and has only added the newer ones.
2.) This is how I have it set up right now - and like I said, it does work, although I get the error message which is sure to alarm the end users. I'll describe how it works, and if anyone can see an immediately obvious way to make this less circuitous and more elegant, by all means clue me in.
Big thanks to everyone who's taken time to help me work this stuff out. I, too, am finding out that the more versed I become in Access, the more I come across things that still seem new or puzzling.
So: The situation is, I have a form which of course sends data to its underlying table; but if a user chooses, I want some of the data to also be sent to a second table, whose relevant field names match the primary table. How I've set this up is with an append query - if a box is check in the primary table (and thus in the query), the fields are appended to the second table. In the form, I've included the box to check, and a command button underneath it to run the append query. So the user would check the box, signifying that this data is to be sent to the second table, and then click the button, signifying 'do it now,' essentially. And, because there are other records which have previously been added to the form, the query is at this point trying to add them again, realizing that it can't (because doing so would duplicate a value in a primary key) and returning an error message to the tune of "none of the duplicate records were added."
The biggest thing that would help me is learning a way to tell the query that it's only supposed to add fields which are NOT duplicates, i.e., that are new.
Any advice?
Thanks a lot,
Spherey