Combo box value depends on the selection of another combo box

The combo box data depends on selection on another combo box

Two combo boxes have been related to each other. The data list on the second combo box will depend on the selected value on the first combo box. How to make it works?

Step #1  Create two combo box on form. The first combo box, in this How To, will select data from the Customer Type table. Select option “I want the combo box to get the values from another table or query” on the Combo Box Wizard. Then select CustomerTypeID and CustomerType fields from table Customer Type.

selectfields

combo box wizard

Step #2 Create the second combo box that looks up data from the table Customer. On the Combo Box Wizard, select option “Find a record on my form based on the value I selected in my combo box.” By this option the customer name the selected from this combo box will show on this form.

selectfield customer name

comboboxwizard

Step #3 After you add two combo boxes, the form will look like below after loaded.

two combo
But, a combined treatment plan is required buy cheap levitra to eliminate cardiovascular disorders and ED. Panic Disorder Treatment Panic disorders are one of the anxiety disorders associated with viagra sale mastercard failure to achieve a satisfactory erection cycle. no rx levitra Due to abnormal leukorrhea, it is not conducive to the sexual life and couple’s relationship. tadalafil 10mg Such things happen as soon as off cuts associated with metabolic rate, described as ketones, increase systems.



Step #4 Requery the second combo box on the After Update Event on First Combo box as shown below:

Private Sub SecondComboBox_AfterUpdate()
Me.SecondComboBox.Requery
End Sub

Step #5 Under the second combo box, edit the record source on property sheet

editqueryCombo

Step #6 Link CustomerTypeID on the query builder to the First Combo Box (Customer Type) on Customer Form.

link CustomerTypeID

Step #7 Finish. After Business Customer Type is selected on the first combo box (Customer type), then the list of customer name with customer type of Business will show on the list on second combo box(Customer name)   see picture below:

select customer name

Combo box under the Navigation Form

If we link the form with combo box under the Navigation Form, the code above will not work. We need to update some code shown below.

combo two combo

1. Update the Requery on the second combo box on the After Update Event on First Combo box as shown below:

requeryFirstBox

Private Sub Combo219_BeforeUpdate(Cancel As Integer)

‘ Combo221 is Select Customer Name combo box

Forms![Navigation Form]![NavigationSubform]!Combo221.Requery

End Sub 

2. Under the second combo box, edit the record source on property sheet. Change from [Customer] to [Navigation Form]![NavigationSubform] as shown below.

updateSecondBox

queryRowSource

Related Video:

 




Related posts