Dependent Dropdown

  • Thread starter Thread starter Drew
  • Start date Start date
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
 
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
 
Back
Top