"Or" operator trouble

trauts05

New member
Local time
Today, 14:37
Joined
Jun 19, 2013
Messages
8
hey so I have this code which filters a form with the command button ("Command 82"), but it only searches in the "TASK_NUMBER" field.
How can I make it search multiple fields at once? I feel like you can just use the "Or" operator, but where do I put it?

Private Sub Command82_Click()
Me.Filter = "TASK_NUMBER Like '" & "*" & Me.Text80 & "*'"
Me.FilterOn = True
Me.Requery
End Sub
 
trauts05, Try
Code:
Private Sub Command82_Click()
     Me.Filter = "TASK_NUMBER Like '*" & Me.Text80 & "*'[B] OR anotherField = 10[/B]"
     Me.FilterOn = True
     Me.Requery
End Sub
 
Just tried that, and it gives error 3464 "Data type mismatch in criteria expression, it's also not recognizing the "OR" as an operator (ie it's not turning blue)
 
Could you please show the code you have? Make sure the types match up.. You cannot look for a String in a Number field..
 
The OR is a valid operator , you need to help Paul to help you by showing your code, the syntax can get complex with its " so mistakes are easy to make.

Brian
 
Hey so it's literally just a command button, it's not a part of a larger code, so what I have is:
Private Sub Command41_Click()
Me.Filter = "ORDERNUMBER Like '" & "*" & Me.Text37 & "*'"
Me.FilterOn = True
Me.Requery
End Sub
 
Also it would be convenient if it can search both numbers and text, not sure if that's an issue in this case...
 
:confused:

I thought that you wanted help with the Or operator?

You lastest code has an extra & in it.

Your text37 control will be defined as a particular data type and thus will always contain that data type.

Brian
 
I've tried taking out all the & symbols individually and it gives an error every time, and I meant that I thought you could just use the "Or" operator somewhere like this (this isn't right but this is what I was thinking of)

Private Sub Command82_Click()
Me.Filter = "TASK_NUMBER Or anotherField Like '" & "*" & Me.Text80 & "*'"
Me.FilterOn = True
Me.Requery
End Sub
 
Try

Me.Filter = "TASK_NUMBER Like '*" & Me.Text80 & "*' or anotherfield Like '*" & Me.Text80 & "*'"

Brian
 

Users who are viewing this thread

Back
Top Bottom