Yes, you can. It is best to do this right after you input the infor that makes up your unique index for the record. Like SS#, ClientID#, etc. So, in the AfterUpdate of the field/last field that comprise this unique identifier put this code with updates for your tables and field names:
Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = db.OpenRecordset("tblYourTable", dbOpenDynaset)
rs.FindFirst("[YourFieldNzme]= '" & Me![FormControlName] & "'"
If rs.NoMatch then
'No matching record in table CONTINUE with Add
else
'Match found - This add would be a duplicate
MsgBox "This record is a duplicate of one already in the table"
Me![FormControlName].SetFocus
End If
rs.close
db.close
This example examines the value in the unique control to the table and if a match is found then displays a warning message and returns control to the control on the form. If no match is found then the focus continues on to the next control and the record can be filled in and saved.
Please post back if you have any troubles with this code.
Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???