My database has table [MCR Table] with primary key field [REA Number] plus several other fields. When entering a new record using [MCR_Input_Form], the REA Number is the first thing entered and gives an error message if that value already exists in the MCR Table. Unfortunately this means that all fields are usually filled and the enter button pressed before the error message appears. This is frustrating and time consuming to the person inputting (my boss) who asked whether I could modify the form so that once the REA number field has been tabbed out of, the REA Number could be checked before proceeding with all the periphery data.
Using the ‘on exit’ event for the REA box I’ve tried the Dlookup code as follows
If IsNull(DLookup("[REA Number]", "[MCR Table]", "[REA Number] = "" & [Forms]![MCR_Input _Form].[REA Number] & """)) Then
Msgbox "Already Exists"
End If
Unfortunately the message ‘already exists’ appears whether the REA Number exists or not .
I can’t see where I’m going wrong. Can any one shed some light please?
Using the ‘on exit’ event for the REA box I’ve tried the Dlookup code as follows
If IsNull(DLookup("[REA Number]", "[MCR Table]", "[REA Number] = "" & [Forms]![MCR_Input _Form].[REA Number] & """)) Then
Msgbox "Already Exists"
End If
Unfortunately the message ‘already exists’ appears whether the REA Number exists or not .
I can’t see where I’m going wrong. Can any one shed some light please?