Append Query from Button

S

Steven M. Britton

I have a button that runs an append query, it adds to an
Orders table (Similar to Northwind), and the OrderID
(AutoNumber) is the primary Key. But if the user clicks
the button twice or three times it adds the records again
and again. I can't change the primary key though because
it is related to the Order_Detail via that ID.

What should I do to prevent adding duplicate data?
 
J

Jim's Back

Your first action in your code should be to check if
records all readys exist. This can be done with a simple
query or filter and then using the recordcount property.
If the result is 0, then append the records,
If the result is >, then exit
 
G

Guest

Can you explain this further, I don't know that I
understand how to do that... But it seems simple enough.
 
G

Guest

Form.Filter = "[Your Field] = Criteria"
Form.FilterOn = True
if Form.RecordSource.RecordCount = 0 then
{insert code for your append}
endIf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top