Searching for a field that is a number

T

Tony Williams

I have a search form with a control called txtsearch. When the user enters
characters into txtsearch and then presses Enter my form shows all the
records which include the characters. However all the controls I'm searching
are text fields but there is one control that is a number field, txtrefnbr
and I want to include that in my search. How do I change my code to add the
number field to the criteria. Here is my code:
Private Sub txtSearch_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'execute search
Debug.Print "Search for " & Me.txtSearch.Value
Me.RecordSource = "SELECT * FROM [qrysearchcomplaint] WHERE
[txtcomplainant] like ""*" & Me.txtSearch.Value & "*"" or [txtbusinessname]
like ""*" & Me.txtSearch.Value & "*"" or [txtsurname] like ""*" &
Me.txtSearch.Value & "*"""
Me.btnShowAll.Visible = True
Me.lblSearch.Visible = False
If Me.RecordsetClone.RecordCount = 0 Then
Me.RecordSource = "qrysearchcomplaint"
Me.txtSearch.SetFocus
Me.btnShowAll.Visible = False
MsgBox "No records found for your search criteria",
vbInformation, strAppName
Me.lblSearch.Visible = True
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top