Hi, I'm working on a form and have several combo boxes on it for choosing which data to enter. I am trying to alter the rowsource for a combobox using vba in the AfterUpdate event of the first combobox.
Clear as mud so far?
This is the code I am using and nothing is happening. I have tried using the .Value method for the combobox but nothing worked there either.
The data in the rowsource for Cbo_PPE_Type is in the form of a list, so I don't know if that has repercussions.
Also, and this is perhaps a daft one, do I set the RowSource for combobox Cbo_Item to nothing as its default value as it will be altered, or not in this case, by the code I am trying to implement.
Cheers, Lol
Clear as mud so far?
This is the code I am using and nothing is happening. I have tried using the .Value method for the combobox but nothing worked there either.
The data in the rowsource for Cbo_PPE_Type is in the form of a list, so I don't know if that has repercussions.
Also, and this is perhaps a daft one, do I set the RowSource for combobox Cbo_Item to nothing as its default value as it will be altered, or not in this case, by the code I am trying to implement.
Cheers, Lol
Code:
Private Sub Cbo_PPE_Type_AfterUpdate()
Dim strSQL As String
Select Case Me.Cbo_PPE_Type.Text
Case "Clothing"
strSQL = "Select Clothing_Description From Tbl_Clothing;"
Case "Helmet"
Me.Cbo_Item.Visible = False
Case "Mask"
strSQL = "Select Mask_Type from Tbl_Mask;"
Me.Cbo_Item.RowSource = strSQL
Me.Cbo_Item.Requery
End Select
End Sub