Now then
This is probably seriously easy but i cant for the life of me get it to work properly!
i want a message to appear if a number has already been entered in to the table, i reckon DLookup is the way to go but i could be wrong
My table tblStaff has a field StaffID now when entering a new record in to the form in the txtStaffID field if the staffID is already in the table (ie a duplicate) it brings up a message box with "duplicate blah blah blah" if its not a duplicate it does nothing
StaffID is a numerical value and ive tried almost every combination of ()'s, ""s, 's and []'s but i always get errors or the message box appears everytime regardless of if its a duplicate or not.
also can Dlookup be "nested" like in excel?
eg if i had another field call YearJoin the messagebox would only appear if the StaffID and YearJoin were the same on the same record
Thanks in advance
This is probably seriously easy but i cant for the life of me get it to work properly!
i want a message to appear if a number has already been entered in to the table, i reckon DLookup is the way to go but i could be wrong
My table tblStaff has a field StaffID now when entering a new record in to the form in the txtStaffID field if the staffID is already in the table (ie a duplicate) it brings up a message box with "duplicate blah blah blah" if its not a duplicate it does nothing
Code:
If DLookup("[StaffID]", "tblStaff", "StaffID = " & Me.txtStaffID) Then
MsgBox "Sorry Duplicate Number, Please Try Again", vbInformation
Else
Exit Sub
End If
StaffID is a numerical value and ive tried almost every combination of ()'s, ""s, 's and []'s but i always get errors or the message box appears everytime regardless of if its a duplicate or not.
also can Dlookup be "nested" like in excel?
eg if i had another field call YearJoin the messagebox would only appear if the StaffID and YearJoin were the same on the same record
Thanks in advance