Combo Box Series Requery

G

Guest

I have three related combo box fields that reflect 3 different tables

Are
Location (1 Area : M Locations
Site (1 Location : M Sites

The data source of the Area Combo is a Table/Query (Area Table). Works fine
The data source for the Location Combo is a Table/Query (Area-Location Query). Area is the foreign key of the Location Table
The data source for the Site Combo is a Table/Query (Location-Site Query). Location is the foreign key of the Site Table

This works fine the first time through - i.e. when choosing an Area for the first time, the Location combo box list only includes the Locations for the area entered. When choosing a Location for the Area, the Site Combo list only displays Sites for that area

If I go back and change the Area or Location (while still in the form, or after leaving and coming back in), I still get the original lists with the original foreigh key values to choose from. I've tried requery code in various places but it doesn't ever work.

How do I get this to work consistently? Sorry about the long convoluted question...

Frustrated in Anchorage
 
N

Nikos Yannacopoulos

Linda,

While in your form design, set the Before Update or On Change event of each
of the first two combos to run a macro with a single Requery action on the
next combo, or a line of code that does the same, like:
Me.cboLocation.Requery,
or
Me.cboSite.Requery

changing cboLocation and cboSite to the actual combo names.

HTH,
Nikos

Linda said:
I have three related combo box fields that reflect 3 different tables.

Area
Location (1 Area : M Locations)
Site (1 Location : M Sites)

The data source of the Area Combo is a Table/Query (Area Table). Works fine.
The data source for the Location Combo is a Table/Query (Area-Location
Query). Area is the foreign key of the Location Table.
The data source for the Site Combo is a Table/Query (Location-Site Query).
Location is the foreign key of the Site Table.
This works fine the first time through - i.e. when choosing an Area for
the first time, the Location combo box list only includes the Locations for
the area entered. When choosing a Location for the Area, the Site Combo
list only displays Sites for that area.
If I go back and change the Area or Location (while still in the form, or
after leaving and coming back in), I still get the original lists with the
original foreigh key values to choose from. I've tried requery code in
various places but it doesn't ever work.
 
G

Guest

Nikos - THANKS. I was trying to requery the underlying Query rather than the COmbo itself. This works a charm.
 

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