filtered list box in a subform

G

Guest

Hi. I hope this is an easy one:

I have a form (sites) with a subform (areas). The forms and subform are
built on a simple one to many relationship between sites and areas (there can
be many areas within a site).

What I want to do is add a list box to the areas subform that will show only
those areas from the site that is selected, or currently active in the master
form. Everytime I add a list box, it displays ALL of the areas regardless of
what site they're from. Please Help!!
 
T

ti976

one quick answer: You will need to use event trigger(s) to requery your
list box's row source. ex: on activate event (not neccesary the best
event location to do this) of main form, refernce the list box control
of the subform and change it's row source then refresh it.
 
G

Guest

one quick answer: You will need to use event trigger(s) to requery your
list box's row source. ex: on activate event (not neccesary the best
event location to do this) of main form, refernce the list box control
of the subform and change it's row source then refresh it.

Thanks for the help, but I'm afraid that I'm going to need a bit clearer
explanation. I tried to do what you said, but it didn't work out.
 
G

Guest

Actually, I think I accomplished what I wanted to do through the query
statement. However, I must refresh the subform every time I make a selection
in the list box on the master form. Is there a way to do this automatically?
For instance is there a way to automatically refresh the subform data when
the list box on the master form is clicked?
 
T

ti976

yes,

the list box has trigger events, in general, you would use the 'After
Update' event of the list box in the main form to refresh the list box
in the subform - something like:
Me.ControlNameOf
SubFormInMainForm.Form.Controls("NameOfListboxInSubForm").Requery;
where ControlNameOf SubFormInMainForm is the name of the control in the
main form that holds the subform and "NameOfListboxInSubForm" is the
name of the listbox in the subform.
Depending on your needs you may need to use a different trigger event
of the listbox in the main form.
 

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