Contents of a drop down box based on the selection in another drop

R

REGREGL

Hello all.

Is it possible to base the contents of one drop down box on the current
selection of another drop down box? For example, lets say I have a table
named "Animals" (with one field named "Animal") and another named "By
Product" (with 2 fields named "Animal" and "By Product"). I then create two
seperate drop downs that get their content from these tables.

If I selected "Cow" from the Animals drop down, I would only like cow
related By Products appear in the "By Products" drop down.

Anyone have an idea how I would accomplish this?

Thanks in advance for any advice you may have.
 
R

REGREGL

Iv'e tried several different methods and the code is just not working. All I
get is a blank combo box.

There are 3 tables involved:

Data
Category List
Subcategories

I have a sub form with 2 combo boxes named

cboCategory
cboSub

in the afterupdate section on the cboCategory combo box, I have the
following script:

Private Sub cboCategory_AfterUpdate()
With Me![cboSub]
If IsNull(Me!cboCategory) Then
.RowSource = ""
Else
.RowSource = "SELECT [sub] " & _
"FROM subcategories " & _
"WHERE [category]='" & Me!cboCategory & "'"
End If
End With
End Sub

While the first combobox (cboCategory) works fine. The second combobox
(cboSub) returns blanks.

Any ideas?
 

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