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!

Dlookup in VB Code using "LIKE"

Status
Not open for further replies.

kb178

IS-IT--Management
Aug 16, 2001
83
0
0
US
I have this code set up to look for duplicate names, which if a dup is found a message pops up:

If Not IsNull(DLookup("ID", "[tbl]", "[First Name]='" & Forms![frm]![First Name] & "' AND [Last Name] = '" & Forms![frm]![Last Name] & "'")) Then ...

This works with an exact dup. But if John J. Doe is already entered and John Doe is entered, the duplicate is not found. What's the correct syntax for [First Name] Like Form!frm![First Name]... ?

Thanks!
 
Don't use Like...
I think is better to use the 'where' clause

for example:

select * from database where name='" & text1.text & "'"

'bind the data retrived and then use this:

if (datasource.recordset.bof) and (datasoucr.recordset.eof) then 'BOF and EOF true = no record in the current recordset
[enter your addnew method]
else ' there are anything in the current datasource
[enter you validation code]
endif

instead of bof and eof u can use the .recordcount
if recordcount=0 (nothing) recordcount =1 (anything)

bye


 
How is that different from what I have? If the where clause has the same thing, it's going to pull only identical data like it already does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top