-
Could someone tell me why this works only sometimes?
It finds results only every now and then when i know there in there. Why?
code:
Public Sub SCHADDEE()
' same as date but for addressee
On Error Resume Next
Dim res4 As String
Dim res5 As String
Dim res6 As String
Dim strInput As String
Set rs = db.OpenRecordset("SELECT * FROM mail")
namequery = InputBox("Enter A Name To Search For", "Name Query")
strInput = namequery
If StrPtr(strInput) = 0 Then
MsgBox "Canceled By User Request", vbInformation, "Name Query"
Else
rs.MoveFirst
Do Until rs.EOF
If rs.Fields("Addressee") Like "*" & LCase(namequery) & "*" Then
res4 = rs.Fields("Addressee")
res5 = rs.Fields("Date")
res6 = rs.Fields("Description")
MsgBox res4, vbInformation, "Addressee"
MsgBox res5, vbInformation, "Date"
MsgBox res6, vbInformation, "Description"
rs.MoveNext
Else
rs.MoveNext
End If
Loop
End If
End Sub
-
Take the "On Error Resume Next" part out, and see if there are acutally any errors, and if there are, fix them.
-
No errors appear!
AAAAAAAHHHHHHHHHHHHH!!!
-
Well ...
Try putting single quotes around the LIKE string:
Code:
If rs.Fields("Addressee") LIKE "'*" & LCase(Whatever) & "*'" Then
'
-