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

dlookup syntax error 1

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
Hi All

Anyone know how to change this to look for the input if it is only part of the data enter in the field
eg if hello is entered then it should return billyhellothere
aswell as just hello
Code:
strSearchCriteria = Nz(DLookup("modelID", "tblmodel", "model = '" & Me.txtSearchDetails & "'"))

i tried
Code:
strSearchCriteria = Nz(DLookup("modelID", "tblmodel", "model = *'" & Me.txtSearchDetails & "'*"))
but got a
syntax error in query expression 'model = *'hello'*'

any ideas?
Thanks


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Your idea is correct, but the positioning is off:

[tt]strSearchCriteria = Nz(DLookup("modelID", "tblmodel", "model = '*" & Me.txtSearchDetails & "*'"))[/tt]
 
Use the like operator:
Code:
strSearchCriteria = Nz(DLookup("modelID", "tblmodel", "model Like '*" & Me!txtSearchDetails & "*'"), "")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you both.

Remou, the amendment you suggested did not completely work, it returned no values. It was the addition of the 'like' comparator as suggested by PHV which did job.



Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top