I am trying to populate a listbox based on option boxes that are chosen in an optiongroup. The optiongroup is called frameTable. I have three tables (Table1 - Table3) that contain the values I want to list in the listbox.
If you choose the first option button, then the stuff in Table1 will populate the listbox. Case 1 below.
If you choose the second option button then...you know the rest.
The option value for each of the buttons are 1,2 and 3 respectively. I am attempting to push the Rowsource property of the listbox based on which button is selected.
When I run the UpdateListBox sub I get a "Runtime Error 424, object required. It doesn't like the action statement of each case statement below.
I am guessing my syntax is wrong or something. Any ideas?
Here is the code.
If you choose the first option button, then the stuff in Table1 will populate the listbox. Case 1 below.
If you choose the second option button then...you know the rest.
The option value for each of the buttons are 1,2 and 3 respectively. I am attempting to push the Rowsource property of the listbox based on which button is selected.
When I run the UpdateListBox sub I get a "Runtime Error 424, object required. It doesn't like the action statement of each case statement below.
I am guessing my syntax is wrong or something. Any ideas?
Here is the code.
Code:
Sub UpdateListBox()
Select Case [Forms]![frmMain]![frameTable]
Case 1
[Forms]![frmMain]![lstElements].[RowSource] = "SELECT tblTable1.FieldName, tblTable1.Element FROM tblTable1;"
Case 2
[Forms]![frmMain]![lstElements].[RowSource] = "SELECT tblTable2.FieldName, tblTable2.Element FROM tblTable2;"
Case 3
[Forms]![frmMain]![lstElements].[RowSource] = "SELECT tblTable3.FieldName, tblTable3.Element FROM tblTable3;"
End Select
End Sub