Filter

  • Thread starter Thread starter Ayala
  • Start date Start date
A

Ayala

Hi,
I have a form with fields such as Project Name,
Description and drawing No.
I want to open this form filtered. The filter criteria
will be given by the user in a form called frmFilterBy. In
this form, the user types any word or numbre which will be
the Key word for the filter.
I know that a:
Dim strFilter as String
strFilter = "FieldName Like " & Me.txtSomething will
filter based on one field
But how does the syntax will look like if I want to
display all the fields (Project name, Description and
drawing no) where the Key string appears?

thx.
 
Ayala said:
I have a form with fields such as Project Name,
Description and drawing No.
I want to open this form filtered. The filter criteria
will be given by the user in a form called frmFilterBy. In
this form, the user types any word or numbre which will be
the Key word for the filter.
I know that a:
Dim strFilter as String
strFilter = "FieldName Like " & Me.txtSomething will
filter based on one field
But how does the syntax will look like if I want to
display all the fields (Project name, Description and
drawing no) where the Key string appears?

The right side operand of Like must be a string, so you need
to put quotes around it. If the user is not expected to
include wildcard characters in the Something text box then
you should include them in the filter.

You can use multiple criteria by using the And or Or
operators (in this case Or). so you want to use something
like:

strFilter = "Project Like ""*" & Me.txtSomething _
& "*"" Or Description Like ""*" & Me.txtSomething _
& "*"" Or Drawing Like ""*" & Me.txtSomething & "*"" "
 
Back
Top