Want error message if value exists in table

keyel1971

Registered User.
Local time
Today, 07:21
Joined
Sep 29, 2011
Messages
22
I have a date field in a table (tbl_BO_CIC_Open_Recv) named "RepMo".

I have a date field in a form (FormMaster) also named "RepMo".

Now, when the user enters a value in FormMaster for "RepMo", I want Access to check and see if the value already exists in tbl_BO_CIC_Open_Recv (again, the field name to check in the table is also "RepMo").

No matter what I try, I can't seem to get it to work. Tried queries and conditional macros. I'm not too good with VBA.

Any help would be greatly appreciated.
 
In the Before Update event of the RepMo on the form. Then you would use

Code:
If DCount("*", "tbl_BO_CIC_Open_Recv", "[RepMo]=#" & Me.RepMo & "#") > 0 Then
   MsgBox "This already exists", vbExclamation, "Record Exists"
   Cancel = True
   Me.RepMo.Undo
End If

If RepMo is an actual full date then what I have above should work. If it isn't, let me know as it would need to be modified.
 
It worked fine - thanks so much!
 

Users who are viewing this thread

Back
Top Bottom