Simple issue, "like" operator trouble

trauts05

New member
Local time
Yesterday, 23:06
Joined
Jun 19, 2013
Messages
8
Hey so I have a table with a field called ORDERNUMBERS, and so far I have a text box (Text37) and a command button (Commmand41)

Private Sub Command41_Click()
Me.Filter = "ORDERNUMBER = '" & Me.Text37 & "'"
Me.FilterOn = True
Me.Requery
End Sub

The only problem is that it searches for EXACTLY what is written in the text box, so if I'm searching for 12345 and type in 123 it won't show up.

I feel like it's just a matter of where I put the "like" operator, but I can't figure it out.:banghead:

Cheers
 
try,
Like "*" & Text37 & "*"

Dale
 
where in the code would you put that?
because i tried replacing the

Me.Text37 & "'"
'with
Like "*" & Text37 & "*"

and it doesn't do anything different
 
Private Sub Command41_Click()
Me.Filter = "ORDERNUMBER Like " & "*" & Text37 & "*"
Me.FilterOn = True
Me.Requery
End Sub

You may have to play with the quotes around Text37.
I don't know if it is a number or text.
Assuming that it is a number.

Dale
 
awesome! so it worked when I did
Private Sub Command41_Click()
Me.Filter = "ORDERNUMBER Like '" & "*" & Me.Text37 & "*'"
Me.FilterOn = True
Me.Requery
End Sub

Also does anyone know where I'd put the "Or" operator to make it search several fields at once?
 
An or in a query is not putting the criteria on the SAME line.
Drop down 1 line and put the same criteria in the field you want to filter using the other text box name for Text37.

Dale

FYI, Putting criteria on the same line in a query = an AND.
Putting criteria on another LINE down = an OR.
Use the SQL view to check your query statements.
 

Users who are viewing this thread

Back
Top Bottom