Populating ComboBox based on Option button

Massamiya

Registered User.
Local time
Tomorrow, 03:16
Joined
Jan 28, 2011
Messages
16
I have a check Box, a comboBox and 2 option buttons (OptbtnA & OptbtnB) in an option group on the mainform and have created 2 select queries (qry_btnA and qry_btnB) based on 2 different tables (ProdMain & ProdAux).
I want that when the checkbox is checked and the user selects an option button the appropriate query is run and the comboBox is loaded with data from the corresponding table.
For example,If the checkbox is checked and option button "OptbtnA" is selected query "qry_btnA" (Select distinct ProdName from ProdMain)
would be executed.
and when the checkbox is checked and option button "OptbtnB" is selected query "qry_btnB" (Select distinct ProdName from ProdAux) would be executed.
Don't know whether it is possible to use an IIF() on the row source of the combo box ? like IF(Frame1=1,"qry_btnA","qry_btnB"
I am lost on what I have to do and desperately need help.
 
You can set the Row Source of the combo in the form's On Current event and also in the On Click events of the check box and the option Group, something like;
Code:
If Me.ChecName = -1 And Me.OptionName = 1 Then
     Me.CombName.RowSource = "QRY_Query#1
ElseIf Me.ChecName = -1 And Me.OptionName = 2
     Me.CombName.RowSource = "QRY_Query#2 Then
Else
     Me.CombName.RowSource = "QRY_Query#3
End If
 
John,
Thanks a million,
It is working as advised, couldn't place in the on-click-event of the
checkBox since the checkBox is dynamically checked and unchecked.
But putting the code in the current event of the form did the trick.
I was thinking of a easy way out by trying to use an IIF() function in
the comboBox rowsource to switch between tables which I didn't know
isn't possible.
More grease to your elbow.
 

Users who are viewing this thread

Back
Top Bottom