Form Filter

S

Shelly

I have an unbound textbox and a command button. I've got
code that will filter my subform based on what is entered
in the unbound text box. I have this working when it
matches the full field. What I need is to modify the
Name filter to use wildcards. My users need to be able
to enter a portion of a hospital name and get anything
that has that in it. For example, the type in Community
and get all the hospitals that have Community in the
hospital name.

Here's the code I have working for all the other filters.

Form.Filter = "[HospitalName] Like 'Forms![GPO
Listings]!AmerinetList.Form![NameFilter]'"

Form.FilterOn = True

I've tried all sorts of versions using wildcards in the
code and in the user entered text. I've got to be doing
somthing stupid for this not to work. Any help would be
appreciated.

Shelly
 
G

Gerald Stanley

Try
DoCmd.ApplyFilter , "[hospitalName] like '*" & Forms![GPO
Listings]!AmerinetList.Form![NameFilter] & "*'"

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have an unbound textbox and a command button. I've got
code that will filter my subform based on what is entered
in the unbound text box. I have this working when it
matches the full field. What I need is to modify the
Name filter to use wildcards. My users need to be able
to enter a portion of a hospital name and get anything
that has that in it. For example, the type in Community
and get all the hospitals that have Community in the
hospital name.

Here's the code I have working for all the other filters.

Form.Filter = "[HospitalName] Like 'Forms![GPO
Listings]!AmerinetList.Form![NameFilter]'"

Form.FilterOn = True

I've tried all sorts of versions using wildcards in the
code and in the user entered text. I've got to be doing
somthing stupid for this not to work. Any help would be
appreciated.

Shelly
.
 
G

Guest

Thank Gerald. This didn't quite get it, but it got me
close enough. For some reason I had to set the criteria
to a variable and put the variable into the code
statement.

It's working...thanks for the help
Shelly
 

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