Filter Options in Form

M

MacNut2004

Hello,

I have 2 dropdowns in a form. Region and Location. The first, is called
Region. There are choices of Region in there based on a property list table.
Once a region is selected, I would like that to then filter the Location
dropdown, only showing locations that are associated with that region.

How would I go about doing this?

Thanks a lot!
MN
 
D

Dale Fye

Depends on what your table structure looks like. Lets assume you have a
single table tblA with fields Region and Location. In this scenario, the
query behind your Region combobox (cboRegion) might look like:

SELECT DISTINCT [Region] FROM tblA
ORDER BY [Region]

and the SQL behind the Location combo box (cboLocation) might look like:

SELECT [Location] FROM tblA
WHERE [Region] = Forms!YourFormName.cboRegion

Then, in the AfterUpdate event of cboRegion, I would require the location
combo box. Something like:

Private Sub cboRegion_AfterUpdate

me.cboLocation.Requery

End Sub
 
F

fredg

Hello,

I have 2 dropdowns in a form. Region and Location. The first, is called
Region. There are choices of Region in there based on a property list table.
Once a region is selected, I would like that to then filter the Location
dropdown, only showing locations that are associated with that region.

How would I go about doing this?

Thanks a lot!
MN

The Region and Location fields in the table are both Text datatype?

Leave the Location Rowsource property blank.
Set the RowsourceType property to Table/Query.
Code the Region AfterUpdate event:

Me.Location.Rowsource = "Select PropertyTableName.Location from
PropertyTableName Where PropertyTableName.Region = """ & Me.Region &
""""
 

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