Search string through form

  • Thread starter Thread starter Ramesh
  • Start date Start date
R

Ramesh

Hi,

Is there a way i can search for a string in a field, like a filter? Right
now, i am right clicking and using Filter for *<name>* to find records with
<name> in the field.

Tried to use a parameter query to input the string, but that doesnt work.
Ideally i d liek to be prompted for the string and then all the records
which contain the string be displayed.

Thanks for any inputs.
ramesh
 
Ramesh said:
Hi,

Is there a way i can search for a string in a field, like a filter? Right now,
i am right clicking and using Filter for *<name>* to find
records with <name> in the field.

Tried to use a parameter query to input the string, but that doesnt
work. Ideally i d liek to be prompted for the string and then all the
records which contain the string be displayed.

Thanks for any inputs.
ramesh

In Clcick event of a button...

Dim RetVal as string
RetVal = InputBox("Please Enter Text to Filter On")

If RetVal <> "" Then
Me.Filter = "SomeField = '" & RetVal & "'"
Me.FilterOn = True
End If
 
Ramesh,

Rick is correct, though I would prefer to change his line:

Me.Filter = "SomeField = '" & RetVal & "'"

to:
RetVal = Replace(RetVal, "'", "''")
Me.Filter = "SomeField Like '*" & RetVal & "*'"

This will allow you to use wildcards and apostrophes with the filter.

Dave Emmert
 

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

Back
Top