macro that checks data

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
 
S

Steve Schapel

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
 

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