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!

if statement using "like" will not work

Status
Not open for further replies.
Oct 6, 2002
60
US
Good day all,

I am having a terrible time with the following code. I keep getting a "type mismatch error" If I use an "=" (without all the wildcard syntax) instead of "like" it works fine but I really need the "like statement" any help would be greatly appreciated. Here is the code.

Public Sub Warning_Done()
Dim myuser As Integer
Dim dbs As Database
Dim rst As Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select * from tblWarning")
myuser = Forms!frmCalender!User
rst.MoveFirst

Do Until rst.EOF = True
If rst!UserID = myuser Then
MsgBox "table: " & rst!warningtype
MsgBox "forms: " & Forms!frmCalender!warning
If rst!warningtype.Value Like "chr(34)" * " & Forms!frmCalender!warning.value & chr(34)" * "" And rst!warningDone = False Then
Forms!frmCalender!warning.Visible = True
End If

End If
rst.MoveNext

Loop
End Sub

thanks,
Boomer
 
I believe it should read:

If rst!warningtype.Value Like "chr(34) * " & Forms!frmCalender!warning.value & " * chr(34)" And rst!warningDone = False Then


Or try

If rst!warningtype.Value Like """" & " * " & Forms!frmCalender!warning.value & " * " & """" And rst!warningDone = False Then

The second asterisk seemed to be in the wrong place and there was an extra double quote with each chr(34)

The second example uses four double quotes instead of the chr(34)...usually produces the same results for me. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top