Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate code

Status
Not open for further replies.

xoymas

Technical User
Jun 6, 2001
34
US
Hi I'm trying to put this code for a form to check duplicate values such as last names but I get a compile error.I have Office2000 rpofessional.Here is the code I tried.
Private Sub State_AfterUpdate()
IfNot IsNull(DLookup("[LastName]", "Customers", "CustomerID=" & Forms!Customers!LastName & "") Then MsgBox ("That entry used,blah..")
End If

End Sub

I hope anybody can help me thanks

 
One thing I see that may be a problem is in the Where part of the DLookup. You are equating an ID to a name. Shouldn't it be either the LastName = the LastName textbox on the form? Also if you are looking for the last name, you will need the tick marks (apostrophe) like so...

("[LastName]", "Customers", "LastName = '" & Forms!Customers!LastName & "'")

ljprodev@yahoo.com
ProDev
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top