Hi Team I need a help!
I am trying to make a ComboBox in a Form to show only the values related to the selection of other ComboBox. I created two macros in the Child ComboBox: The first is a ENTER Event, and changes the rowsoure to show only the values related to the ComboBox selection on the first ComboBox, the second is an Exit event, that changes back the query to show all available values. I also created a macro in the master ComboBox to clean the child ComboBox once I change the selection in the Master ComboBox.
I created 3 codes:
1- The first code erases the child ComboBox column, called "Categoria_2"selection
2- the second is a ENTER event where the list is filtered to show only the values based on the Master ComboBox column (cdo_categoria_1) selection.
3- The third code is a EXIT event to return the query that shows all records from the Child table.
For some reason, my table has some bugs and when change rows in the child column the value of the last selected row in the child column simply disappear.
Code:
Private Sub cdo_Categoria_2_Enter()
'MsgBox (cdo_Categoria_1)
cdo_Categoria_2.RowSource = "SELECT [tbl_Categoria2].[ID], [tbl_Categoria2].[Categoria_2], [tbl_Categoria2].[Categoria_1_2] FROM tbl_Categoria2 WHERE [categoria_1_2] = [cdo_Categoria_1] ORDER BY [Categoria_2] "
End Sub
Private Sub cdo_Categoria_2_Exit(Cancel As Integer)
cdo_Categoria_2.RowSource = "SELECT [tbl_Categoria2].[ID], [tbl_Categoria2].[Categoria_2] FROM tbl_Categoria2 ORDER BY [Categoria_2]"
End Sub
Private Sub cdo_Categoria_1_AfterUpdate()
cdo_Categoria_2 = ""
End Sub
so, when I change the comboBox from Categoria_2 column, the value of the last active row disappear.
Pls help !!