macro that checks data

  • Thread starter Thread starter pedro
  • Start date Start date
P

pedro

I have created a control on a form to enter data and wanted to create a
macro which checked if the data entered appeared on a query. If the data
entered did appear on the query then a message box would appear. The message
box would be for information to the user and be something like 'The data
entered has been entered previously in the database' Essentially the macro
would be checking for duplicates.
I don't have a problem creating the query for this but I am unsure of how to
create the macro on the form which would trigger this event. I presume it
would be an 'after update' macro. Any suggestions from this point would be
greatly appreciated.

thanks,

pedro
 
Pedro,

Yes, the After Update event of the control would probably be the best
choice.

Based on what you told us so far, you don't need a query. You can just
check back to the table. Make your macro with a MsgBox action, and in
the Condition, put the equivalent of:

DCount("*","YourTable","[TheField]='" & [TheControl] & "'")>0
 
Back
Top