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!

Is there an IsLike? 1

Status
Not open for further replies.

ICCIIT

Technical User
Jul 21, 2003
62
GB
Is there an Is Like operand that can be used in module code?

I want to pass a string variable through to a function and then get the the function to evaluate it using a like statement such as you might do a in a query criteria

If MyString is like *"Hello"* then

....

End if

Thanks

 
When in VBE put the cursor inside the Like word in your code and then press the F1 key.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Now getting a type mismatch and yet both parts are string

I am passing the word "Current" as variable IBNRTxt

Code:
Public Function IBNRCat(IBNRtxt As String) As String
Dim Checkstring As Boolean

If Checkstring = [IBNRtxt] Like "Current" Then
IBNRCat = "Found"
End If
Any ideas why this is failing on an exact match?
 
No [], just IBNRtxt
If Checkstring = [IBNRtxt] Like "Current" Then
 
A simpler way:
If IBNRtxt Like "Current" Then
IBNRCat = "Found"
End If

Anyway, why using the Like operator with NO wildcar ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks to you both... just one more step (I think)

PHV you are too psychic for your own good!

The wildcard question was coming next I just wanted to get a working result on an exact match first before moving on to that.....

So now this is working, I want to pass "Curr" and get a true result

The Access help notes on this are not very clear about wildcards..
 
If IBNRtxt Like "Curr*" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV
I thought I had tried that and it failed.... I just did it again and its fine!!

Thats great thanks very much and a Friday start for U
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top