Update combo box choice based upon another combo box

T

Todd

I'm trying to make one combo box on a form have its
rowsource updated based upon entry into another combo box.

The source table for the combo box values looks like this:

StatID, Stat, Stat2
1, Frozen, Freezer 1
2, Frozen, Freezer 2
3, Off-site, Germany
4, Off-site, England
5, In-process, n/a

The AfterUpdate code for the primary combobox is this:

Private Sub StatusCombo_AfterUpdate()
Me.Status2Combo.RowSource = "SELECT Stat2 from
PickTestTable where Stat = " & Me.StatusCombo & " Order by
Stat2"
Me.Status2Combo = Me.Status2Combo.ItemData(0)
End Sub

It keeps asking me for a parameter when I try to use the
first combobox. If I enter one of the Stat entries into
the parameter box, it actually works, obviously I don't
want to have to do this.

Can someone help?
 
T

tina

you don't need to set the rowsource for the second combo
box each time. enter it directly in the properties box, as

SELECT Stat2 FROM PickTestTable WHERE Stat = [Forms]!
[FormName]![StatusCombo] ORDER BY Stat2

then change your sub to

Private Sub StatusCombo_AfterUpdate()

Me!Status2Combo.Requery

End Sub

hth
 

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