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

Search String syntax error 1

Status
Not open for further replies.

mrf1xa

Technical User
Jan 14, 2002
366
GB
Hi, could someone save me from pulling my last few grey hairs out please - sure I am missing the obvious.

i am using a series of combos to filter down records, and for the most part it works fine - snippet below does for example:

' If Project Name
If Not IsNull(Me.cboProjName) Then
'Create Predicate
strWhere = strWhere & " AND " & "tblContracts.[Project Name] = '" & Me.cboProjName & "'"
End If

However for one field I need to wildcard search as there are great inconsistencies in the way they have been keyed. Using the following filter on the form gives me exaclt what i want:

(((tblContracts.[Supplier Name]) Like "*" & "IBM" & "*"))

So I tried to build this into my search string like this:


' If Supplier name
If Not IsNull(Me.cboSupplier) Then
'Create Predicate
str = Me.cboSupplier
strWhere = strWhere & " AND " & "(((tblContracts.[Supplier Name]) Like '" * " & str & " * "'))"

End If

But I get a type mismatch error, despite having tried every combination I can think of. Could someone point me the right way please?

Thanks in advance.


Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Code:
strWhere = strWhere & " AND tblContracts.[Supplier Name] Like '*"  & str & "*'"


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Brilliant, works perfectly, many thanks!

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Apologies for the delay, only just seen I had another reply on this.

Interesting point dhookum - I wonder what level of help warrants the star as opposed to a quick thank you note? I know stars count towards tip master etc.....

Not to decry at all the valuable steer PHV gave me, I am sure it was a few seconds work for him along with a thought along the lines of "what is this idiot doing with his syntax?" When you compare that with some of the help I have had in the past, where people have been kind enough to come up with code solutions or read through huge chunks of mine to find a silly error etc - where I have given a star - I wonder where the correct level is?

On other forums I belong to the one-line fix would be given a quick thanks, the bigger stuff more official recognition. If the "rule" on this forum is give a star for every level of help I am happy to fit in, just wondering what other think....

And sorry PHV if I have diddled you out of a star, if the concensus is I am wrong I will award it pronto!

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
IMO, a star signifies the thread has been "closed" because someone has provided the answer. I don't think it matters if the starred person spent hours or just seconds in the reply.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top