Append Query from Button

  • Thread starter Thread starter Steven M. Britton
  • Start date Start date
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?
 
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
 
Can you explain this further, I don't know that I
understand how to do that... But it seems simple enough.
 
Form.Filter = "[Your Field] = Criteria"
Form.FilterOn = True
if Form.RecordSource.RecordCount = 0 then
{insert code for your append}
endIf
 
Back
Top