I have a list box for States of the U.S. and 2 associated option buttons.
The option buttons were meant to toggle the Multiselect property of the listbox between Multiselect None or Simple.
One option button which I made the default is labeled as Group By (the choices are ALL, Group A states and Group B states).
The second option button allows the user to select individual state(s) and I wanted to change the Listbox to Muliselect when the user chooses the option button Individual States.
The listbox has a default value of lstStates.Multiselect equal None.
Is it possible for the Listbox to be non Multiselect upon the Form Load. Then if the user clicks on the option button for Individual States, the list box changes to a multiselect state.
When I use VBA code as follows, I get the error message
Runtime Error '2448' You can't assign a value to this object'
Is there another way for me to code the toggling of the Multiselect property of the Listbox (between 0(none) and 1 (simple) to avoid this runtime error I get ? Frame60 represents the object group for the 2 option buttons.
Private Sub Frame60_AfterUpdate()
Dim strOptStateSelect As String
Select Case Me.Frame60.Value
Case 1
strOptStateSelect = "G"
Me!lstStates.MultiSelect = 0
Call UpdateValueToStateGrList
Case 2
strOptStateSelect = "I"
Me!lstStates.MultiSelect = 1
Call UpdateValueToStateIndList
End Select
End Sub
Private Sub UpdateValueToStateGrList()
Dim strSQLGrState As String
strSQLGrState = Chr(34) + "ALL" + Chr(34) + ";" + Chr(34) + "FALL STATES" + Chr(34) + ";" + Chr(34) + "SPRING STATES" + Chr(34) + ";"
Me!lstStates.RowSourceType = "Value List"
Me!lstStates.RowSource = strSQLGrState
'Me!lstStates.MultiSelect = 0
Me!lstStates.Requery
End Sub
Private Sub UpdateValueToStateIndList()
Dim strSQLIndState As String
strSQLIndState = "SELECT DISTINCT STATEFS FROM tblStatesAll ORDER BY STATEFS"
Me!lstStates.RowSourceType = "Table/Query"
Me!lstStates.RowSource = strSQLIndState
'Me!lstStates.MultiSelect = 1
Me!lstStates.Requery
End Sub
The option buttons were meant to toggle the Multiselect property of the listbox between Multiselect None or Simple.
One option button which I made the default is labeled as Group By (the choices are ALL, Group A states and Group B states).
The second option button allows the user to select individual state(s) and I wanted to change the Listbox to Muliselect when the user chooses the option button Individual States.
The listbox has a default value of lstStates.Multiselect equal None.
Is it possible for the Listbox to be non Multiselect upon the Form Load. Then if the user clicks on the option button for Individual States, the list box changes to a multiselect state.
When I use VBA code as follows, I get the error message
Runtime Error '2448' You can't assign a value to this object'
Is there another way for me to code the toggling of the Multiselect property of the Listbox (between 0(none) and 1 (simple) to avoid this runtime error I get ? Frame60 represents the object group for the 2 option buttons.
Private Sub Frame60_AfterUpdate()
Dim strOptStateSelect As String
Select Case Me.Frame60.Value
Case 1
strOptStateSelect = "G"
Me!lstStates.MultiSelect = 0
Call UpdateValueToStateGrList
Case 2
strOptStateSelect = "I"
Me!lstStates.MultiSelect = 1
Call UpdateValueToStateIndList
End Select
End Sub
Private Sub UpdateValueToStateGrList()
Dim strSQLGrState As String
strSQLGrState = Chr(34) + "ALL" + Chr(34) + ";" + Chr(34) + "FALL STATES" + Chr(34) + ";" + Chr(34) + "SPRING STATES" + Chr(34) + ";"
Me!lstStates.RowSourceType = "Value List"
Me!lstStates.RowSource = strSQLGrState
'Me!lstStates.MultiSelect = 0
Me!lstStates.Requery
End Sub
Private Sub UpdateValueToStateIndList()
Dim strSQLIndState As String
strSQLIndState = "SELECT DISTINCT STATEFS FROM tblStatesAll ORDER BY STATEFS"
Me!lstStates.RowSourceType = "Table/Query"
Me!lstStates.RowSource = strSQLIndState
'Me!lstStates.MultiSelect = 1
Me!lstStates.Requery
End Sub