Dependent Dropdown

D

Drew

Can anyone help me out in building a dynamic dependent dropdown for a form
in an Access ADP? I have the following tables on my SQL Server

EventCat
CatID - Value for parent dropdown
Category - Labels for parent dropdown

EventSubCat
SubCatID - Value for child dropdown
CatID - relation to EventCat table
Subcategory - Label for child dropdown

I need to make a dropdown that populates from EventCat table and a second
dropdown that populates from EventSubCat depending on the EventCat dropdown
value.

Does anyone have any pointers for doing this?

Thanks,
Drew
 
D

Drew

Found my answer... here it is...

2 dropdowns, ddlCatID and ddlSubCatID

Set the ddlCatID (parent) to populate from table or query, then set
ddlSubCatID.RowSource to nothing. Then on the After Update event, you need
to following code,

Private Sub ddlCatID_AfterUpdate()
On Error Resume Next
ddlSubCatID.RowSource = "SELECT SubCatID, CatID, Subcategory " & _
"FROM EventSubCat " & _
"WHERE CatID = " & ddlCatID.Value & " " & _
"ORDER BY Subcategory;"
End Sub

This just sets the child dropdown to filter the db by CatID.

HTH,
Drew
 

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