using combobox in main form to filter subform

G

Guest

I have a main form with a subform. The subform is based on [query_sub]. I
created a combobox [combo12] in the main form and made one of the where
clauses in [query_sub] equal to [mainform].[combo12]. All worked well except
it won't update when the choice in the combobox was changed. So I added a
small macro to requery on 'after update' of combo12. But.... I can't seem to
name the control properly because the query (and it's fields) are in a
subform. I've tried to requery forms.[main form].[sub form].form.[field
name] but that doesn't work (as well as the query_sub and a couple of
others). What should I be requerying? Have I done this wrong? I saw one
article on doing it with VBA but I'd have to recreate my forms to make them
parent/child. Please help. Thanks Ian.
 
S

Steve Schapel

Ian,

In the Control Name argument in the macro, I think you will only need to
enter the name of the subform, that's all:
Control Name: [NameOfSubformControl]

Presumably you would assign this macro on the After Update event
property of the combo12 combobox.

Another way of doing it, would be to remove the combo12 reference in the
query criteria, and instead you could set the Link Child Fields property
of the subfrom to the name of the field that correspond's to combo12's
value, and set its Link Master Fields property to [combo12].

If the subform already has Link Master Fields and Link Child Fields set,
you can just add the above to the existing.
 

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