Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter data on a subform, how to?

Status
Not open for further replies.

bjayhome

Technical User
Dec 13, 2001
17
0
0
US
Hi All,
How do I filter data on a subform by using a macro?

I have a form named "Directory" and within that a subform named, "Advisors". I want to filter the 'City' field, for an example.

I have created a macro (Where Condition: [Forms]![Directory]![Advisors].[Form]![City] Like "Toronto"), which is run by a Command buttons click event (Docmd.ApplyFilter "xxxx"). This Command button is on my subform not on the main form. It works fine when I just open the subform and run the macro. But when the subform is opened through the main form, it gives me the following error:

"Run-time error '2491':

The action or method is invalid because the form or report isn't bound to a table or query.

You tired to use the ApplyFilter action or method. However, the form or report you applied the filter to is not based on a table or query, so the form or report doesn't have any records to apply a filter to. …"

Can someone please help! ? :-(
 
Did you get any replies to the thing on how to filter a subform? I tried the same darn thing. makes sense that I want to filter the subform and not the mainform where the controls are... why can't access understand this?

There are several pages on the web explaining how to do it, but I don't know how to make the button on the form execute raw code (instead of a macro). My hope of using cut and paste from their "solutions" (yeah right) didn't work.

Let me know and I'll be your friend forever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top