Adding the AND properly

P

Pierre

I have a code that I had some help putting together. I would like to modify
it to allow me to search 2 fields and not just the one its searches now.
Brief overview is that it currently searches for a WORD in a field called
[Definition]. I would also like it to look in a field called [Cat Codes] if
a number code (like 99200) is entered.

Code being used now:

Private Sub Text49_AfterUpdate()
Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*"""
Me.[Cat Codes subform].Form.FilterOn = True
End Sub
 
K

Klatuu

Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*""
AND [Cat Codes] =" & Me.CatCode
 
M

mscertified

Change thuis line
Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*""" to
Me.[Cat Codes subform].Form.Filter = "Definition Like '*" & Me.Text49 & "*' AND [Cat Codes] = '" & Me.CatCode & "'"

substitute the Like syntax if you are not doing an exact match

-Dorian

Pierre said:
I have a code that I had some help putting together. I would like to modify
it to allow me to search 2 fields and not just the one its searches now.
Brief overview is that it currently searches for a WORD in a field called
[Definition]. I would also like it to look in a field called [Cat Codes] if
a number code (like 99200) is entered.

Code being used now:

Private Sub Text49_AfterUpdate()
Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*"""
Me.[Cat Codes subform].Form.FilterOn = True
End Sub
 
P

Pierre

I was really looking for OR and - NOT- AND, but that was a simple fix on my
part. The rest of the code worked,

TY for your response.
--
Work is sometimes hard....but someone has to do it.


mscertified said:
Change thuis line
Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*""" to
Me.[Cat Codes subform].Form.Filter = "Definition Like '*" & Me.Text49 & "*' AND [Cat Codes] = '" & Me.CatCode & "'"

substitute the Like syntax if you are not doing an exact match

-Dorian

Pierre said:
I have a code that I had some help putting together. I would like to modify
it to allow me to search 2 fields and not just the one its searches now.
Brief overview is that it currently searches for a WORD in a field called
[Definition]. I would also like it to look in a field called [Cat Codes] if
a number code (like 99200) is entered.

Code being used now:

Private Sub Text49_AfterUpdate()
Me.[Cat Codes subform].Form.Filter = "Definition Like ""*" & Me.Text49 & "*"""
Me.[Cat Codes subform].Form.FilterOn = True
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