Updating values in combol boxes

crescent-centre

Registered User.
Local time
Today, 23:46
Joined
Feb 28, 2003
Messages
30
I am writing a skills / contact database. I want to select a discipline from a combo box and then select a specialism from a second combo box. This works in table view and in querys but I am not sure how to do this in forms. At the moment the second box displays all the specialisms what ever discipline I select. Can anyone help.
 
The term you are looking for is Cascading Combobox.

Let’s say the topmost category was Continents, and the subcategory was Countries

The table structure would be:

tblContinents
ContinentID – autonumber
Continent – text

tblCountries
CountryID – autonumber
Country – text
ContinentID - number

On our form (we’ll call the form: frmExample – our two combos: cboContinent, cboCountry

The RowSource of the topmost combo is:

SELECT ContinentID, Continent FROM tblContinents ORDER BY Continent;

The RowSource for the second combo is:

SELECT CountryID, Country FROM tblCountries WHERE ContinentID = [Forms]![frmExample]![cboContinent] ORDER BY Country;


On the AfterUpdate event of cboContinent put:

Code:
Me.cboCountry.Requery
 
Thanks. I've set up a new example database following your instructions however when I try to select a value from the continents box I get an error message stating Access can not find the macro 'me'. Any suggestions
 
I gave you code.

Where you've written the Me.combo.Requery delete that and , on the same line, select the button at the far right that has the three dots on it. On this, select Code Builder. In between the module that opens you;ll get this:

Code:
Private Sub MyCombo_AfterUpdate()

End Sub

Add the line I gave between these, changing - of course - the names to suit.
 

Users who are viewing this thread

Back
Top Bottom