ms/access dynamic source for dropdown control

Hi
On my app o have a 4 level table subtable set for a location: Region / Sector / Section / Base. I need to have the user selecting first the [Region] then, only the [Sector] for the selected [Region] should show on the dropdown [Sector] control, then only the [Section] set for the the selected [Region].[Sector] should show on the dropdown.
All the controls have specific proper names, e.g.  [frmfld_Region] for the dropdown control related to Region.
My question is: how do I do it? How do I ensure that the dropdown list is properly managed? (a simple tree as in datasheet view would do ... but I can't simple use it as I loose the "control" management.
João serras-pereiraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertFabrice LambertCommented:
Hi,

you can use the BeforeUpdate event, to refresh or update the next dropdown lists.

This can be as simple as setting the rowSource property, to calling whatever function used to populate the dropdowns.
0
João serras-pereiraAuthor Commented:
Yeap... I was hoping that someone had the actual solution. The rowSource property is a query, as usual. But the query should be dependent on the values of higher level tables and this is precisely what I don't know how to....
0
Fabrice LambertFabrice LambertCommented:
Most of the time, selecting something in a dropdown apply filter in the others.

So it is just a matter of writing the "where clause".
Without knowledge on how your controls are set up, I can only make some guess.

Let's say the rowSource for your Region control is something like:
Select Name
From Region;

And nothing in the rowSource of your Sector control.

On the beforeUpdateEvent, you should call:
Public Sub Region_BeforeUpdate(Cancel As Boolean)
    Sector.RowSource = "SELECT Sector.Name " & _
    "FROM Region INNER JOIN " & _
    "Sector ON Region.ID = Sector.ID" & _
    "WHERE Region.Name = '" & Region.value & ';"
    Sector.Requery
End Sub

Open in new window


Hope you get the idea.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
João serras-pereiraAuthor Commented:
thanks!!! great HELP!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.