Link to home
Start Free TrialLog in
Avatar of Chi Is Current
Chi Is CurrentFlag for United States of America

asked on

Enable Filter by Form on Subform

Access 2010: I would like to use "filter by form" on a subform; however, filter buttons are grayed out.  Is there a way I can enable this functionality on a subform?

"Allow Filters" property = Yes, on subform (and main form) properties
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Your question was originally titled "Enable Filter by Form on Unbound Subform", but it looks like you have edited it.

Is your subform bound or unbound?

Filter by Form will not work on unbound forms... but it does work on *bound* subforms.  The default buttons will appear enabled if you click on any bound control in your subform.
Avatar of Chi Is Current

ASKER

Thank you, mbizup for your reply.

Yes, my subform IS *bound* to a table, though the subform is not in a child / parent relationship to the main form.

I am very surprised to notice ALL the "Sort & Filter" buttons greyed out - even when I place the cursor in a bound control in the subform (!).
Ah - okay.

An alternative would be to set up unbound controls either in the header of the subform (if you are using continuous forms or single form view), or on the main form to filter the subform by code either in the After Update events of those unbound controls or a command button's click event.  Custom filtering of a subform like this is very common, and there are a lot of examples of this here on EE.
Here's a sample (Access 2010) which is a basic example of the idea in my precious post.  This was uploaded in an earlier question.

Fwiw, it also shows the Filter By Form option enabled for a subform, which like yours has no master/child links to the main form.

Maybe if you upload a sample of your database we can pinpoint why this is not working for you.Filters1.accdb
Thank you for your ideas.  Somehow, I'm still not getting this.

Please find example attached.  There are only 3 records in the db; however, the subform displays only ONE of them(?)!  Additionally, using the combo box at the top of the main form, it IS possible to locate AND DISPLAY the other two records.

You can see the 'Sort and Filter' buttons remain grayed out when a textbox in the subform has focus.  ???

Clearly, there is something going on here that I have yet to understand.  I have never had this issue w/ subforms in the past.  Gotta admit, I'm very new to Access 2010....  Perhaps something else different here?

Thank you for your assistance!
EXP-Filter.accdb
I think I confused you by posting two seperate approaches in different comments in the same thread.

For the sample you posted, you should remove the master child links and remove the recordsource for the main form (the recordsource should be blank).

See this sample, and take a look at the After Update code for your combo box.

That code sets the subform filter, and clears it if the combo is null/blank.
EXP-Filter.accdb
Thank you, mbizup.  I see the difference deleting master child links makes.  And I see how you revised the combo box on the main form as a filter.

However, in your example, the "Sort and Filter" buttons in the ribbon bar still remain blank, even when the cursor is placed in a textbox on the subform.  Are you seeing this on your end?

~Jacob
Yes - I am seeing the greyed out buttons.

The solution I suggested was meant as an alternative to the built-in filtering on the ribbons.
How can I restore functionality to the built-in filtering on the ribbons?

Actually, I'm thinking having this in two forms is more hassle than it's worth.  Perhaps it would be better to have all on one form - it's really only cosmetic anyway...
Having the built-in filtering on the ribbons is very useful.
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahhhhh.....  Thank you!!!