Using a button to filter a sub-form - doesn't work when using main form. (1 Viewer)

AndyC88

Member
Local time
Today, 22:16
Joined
Dec 4, 2020
Messages
44
Afternoon all,

I've got the following issue - I have a list of equipment requirements for each individual - and I want to be able to filter them based on their EquipmentCategoryID.

Using the buttons, it works as expected when the form is opened by itself. However, when I try and use the filters when the subform is open on the main form - it doesn't seem to like it and displays the error shown below.

Any pointers much appreciated! :)

Thanks,

Andy
 

Attachments

  • DB_Project.accdb
    1.8 MB · Views: 120
  • Subform_Not_working.JPG
    Subform_Not_working.JPG
    41.7 KB · Views: 120
  • Subform_working.JPG
    Subform_working.JPG
    36.9 KB · Views: 77

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,048
I haven't played much with macroes, but it clearly says that you have to supply the control name if not the parent form.?
 

AndyC88

Member
Local time
Today, 22:16
Joined
Dec 4, 2020
Messages
44
I've read that macros aren't the best method - but I have zero experience writing any kind of code so it's all I can use at present... will take a look now.
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,048
I've read that macros aren't the best method - but I have zero experience writing any kind of code so it's all I can use at present... will take a look now.
I am trying to work out what control it wants, the control for categoryID, the subformcontrol or what ???

I'd start Googling.

Plenty of videos on YouTube
 
Last edited:

AndyC88

Member
Local time
Today, 22:16
Joined
Dec 4, 2020
Messages
44
Thanks Gasman, I watched the video but that's using combo boxes to filter a query. My form is just based on tables - not sure I can get it to do the same?

The control it wants should be the EquipmentCategoryID - so that it filters from a list of ~130 down into a more manageable list. It works fine on the form - but doesn't work as a subform.
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,048
There were plenty of other videos there?

I would stop now TBH and have a rethink. What happens when you have another category? A whole new button and another macro.?
I would start to learn VBA. You have already discovered macroes can be somewhat limited. I still cannot find the syntax for the control and the help does not even mention it. :devilish:

That is your issue in this case. I will keep having a go at the syntax, just for my benefit, but I'd seriously consider using VBA. Even I could help then. :)

Plenty of links on how to filter form/subform, but very few if any on the ground for macros. :(
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2002
Messages
42,976
The form design is pretty but clunky. It is generally poor practice to create designs that require changes if certain data values change and this is one of those cases. A combo is much less attractive than a row of buttons but if you add/delete/change categories, it will continue to work without any change being required unlike your current schema.

Another option is to change the subform to DS view. That automatically gives you filtering options that are very similar to those in excel. And NO programming is required.
 

Users who are viewing this thread

Top Bottom