I'm trying to set up a form with two synchronised combo boxes. I keep running into issues with the code as I'm learning as I'm going.
The first combo box is used to select manufacturer and the second should update to only show models from the manufacturer chosen from the first combo box.
The 'Assets' table contains the 'model' column (the intended result) and a 'manufacturer_id'. This is linked to the 'manufacturer_id' on the 'Manufacturers' table that has a 'name' column (the one selected from the 1st combo box).
This is what I have:
When selecting a value from the first combo box I receive a popup asking for a parameter value for Manufacturers.manufacturer_id. I assume the Dlookup is the problem?
The first combo box is used to select manufacturer and the second should update to only show models from the manufacturer chosen from the first combo box.
The 'Assets' table contains the 'model' column (the intended result) and a 'manufacturer_id'. This is linked to the 'manufacturer_id' on the 'Manufacturers' table that has a 'name' column (the one selected from the 1st combo box).
This is what I have:
Code:
Private Sub cboManufacturer_AfterUpdate()
Dim varManID As Variant
varManID = DLookup("[manufacturer_id]", "Manufacturers", "[name] ='" & Me.cboManufacturer.Value & "'")
Me.cboModel.RowSource = "SELECT model FROM Assets WHERE Manufacturers.manufacturer_id = " & varManID & " ORDER by model"
Me.cboModel = Me.cboModel.ItemData(0)
End Sub
When selecting a value from the first combo box I receive a popup asking for a parameter value for Manufacturers.manufacturer_id. I assume the Dlookup is the problem?