Filtering a combo box using 2 other combo boxes

jjake

Registered User.
Local time
Today, 13:24
Joined
Oct 8, 2015
Messages
291
Hello,

I am trying to filter a combo box based upon a union query.

i have the following structure,

33a73wx.jpg


My union query. The only problem i have with this is instead of showing row 1 (PlantNum or EquipmentType) it shows row 0 (ID). Can i fix this?

15dp18j.jpg


These are my results (BOILERNAME) That i would to display in my final combobox

2j35hdu.jpg


This is my form. The goal is to filter the 3rd combobox based upon matching criteria in PlantNum and EquipmentType. If both of these conditions are met the 3rd combobox, (EquipmentID) will display results that match the criteria.

byhrq.jpg
 
in the property of the combo, set the column widths to 0 if you dont want it to show
colwidths= 0;1;0

the above sets col 1 (col 0 in code, but col 1 in properties, thanks mSoft)
set col 1 to width zero, thus hiding it. Col 2 = 1 inch, col 3 = 0

To do the multi-combo box
each combo box has a query for its recordsource.
Here the user picks a state, then in the next combo picks a Company (in that state)
The 1st combo,(say cboStates)... User picks a state, then picks a company from the cboCo box.
The cboStates AfterUpdate event will trigger when the user picks it, and this will update the next combo.

Code:
sub cboStates_AfterEvent()
 cboCo.requery
end sub

The cboCo query (say qsCoViaState) will reference the cboStates in the query sql
Select * from tCompany where [ST] ='" & forms!frmMain!cboStates & "'"

The CO combo must be refreshed (cboCo.requery action) after user picks the state so it can deliver the resulting dataset.

If there is another combo after this say cboEmps to pick employees, then the cboEmp must be refreshed after user picks cboCo.
Code:
sub cboCo_AfterEvent()
 cboEmps.requery
end sub
 
I got it figured using a different method then you suggested.

I input this into my union query in SQL

iwqiie.jpg


In the Onchange event for my combo boxes I put refresh record so that when I change either cboPlantNum or cboEquipmentType, cboEquipmentID is filtered accordingly.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom