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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if Name already exists? 4

Status
Not open for further replies.

Bauer99

MIS
May 6, 2003
20
0
0
CA
I have a very simple Database tracking Personnel. I have a form for data entry. What I want to do is on the Before Update Event I want to check if the name has already been entered and display a msgbox. The name is Split into two fields - LASTNAME and FIRSTNAME.

I figure you need to put the Last and first name into a single string. Then loop through each record, and compare the names. But I do not know how do do this..... Anyone done this before?
 
There's a shorthand function that does all this called DLookup. The help files will help with the specifics, but it will look *something* like this:

if Not IsNull(DLookup("[LASTNAME] + [FIRSTNAME]","[TABLE_OR_QUERY_NAME_GOES_HERE]","([LASTNAME]+[FIRSTNAME]) = '" & txtLastName & txtFirstName & "'")) then
'item already exists
End If
 
Great! Works like a charm....

Once again... look for the easier solution!
thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top