Good morning everyone, I would like to filter a form with a datasheet subform with two cascading combo boxes and a checkbox. The form is called "SottoCategorie_Attrezzature_Atetica", the subform smProdotti_Attrezzature_Atetica; in the header of the form I inserted the two combo boxes and the checkbox; the first combo box is called cboSceltaSottoCategorie, the second combo box is called "cboSceltaTipo", the checkbox is called chkCatEmmeti.
On the After Update event of cboSceltaSottoCategorie I inserted this code:
Private Sub cboSceltaSottoCategorie_AfterUpdate()
Me.cboSceltaTipo.RowSource = "SELECT IDTipoProdotto, TipoProdotto FROM qrySottoCategorie_TipoProdotto02 WHERE IDSottoCategorie = " & Nz(Me.cboSceltaSottoCategorie, 0)
Me.cboSceltaTipo.Requery
Call FiltraSottomaschera
End Sub
On the After Update event of cboSceltaTipo and chkCatEmmeti I inserted this code:
Private Sub cboSceltaTipo_AfterUpdate()
Call FiltraSottomaschera
End Sub
Private Sub chkCatEmmeti_AfterUpdate()
Call FiltraSottomaschera
End Sub
In the header of the form I inserted this code:
Private Sub FilterSubMask()
Dim filter As String
filter = ""
' Filter by SubCategories
If Not IsNull(Me.cboChoiceSubCategories) Then
filter = filter & "IDSubCategories = " & Me.cboChoiceSubCategories & " AND "
End If
' Filter by Product Type
If Not IsNull(Me.cboChoiceType) Then
filter = filter & "IDTypeProduct = " & Me.cboChoiceType & " AND "
End If
' Filter by Checkbox
If Me.chkCatEmmeti = True Then
filter = filter & "CatEmmeti = True AND "
End If
' Remove the last " AND " if present
If filter <> "" Then
filter = Left(filter, Len(filter) - 5)
End If
' Apply the filter to the subform
Me.Filter = filter
Me.FilterOn = (filter <> "")
End Sub
The filter does not work, in the sense that the second combo box (cboSceltaTipo) does not filter and in the subform all the values filtered by the first box cboSceltaSottoCategorie are returned. Where am I going wrong?
Thanks
On the After Update event of cboSceltaSottoCategorie I inserted this code:
Private Sub cboSceltaSottoCategorie_AfterUpdate()
Me.cboSceltaTipo.RowSource = "SELECT IDTipoProdotto, TipoProdotto FROM qrySottoCategorie_TipoProdotto02 WHERE IDSottoCategorie = " & Nz(Me.cboSceltaSottoCategorie, 0)
Me.cboSceltaTipo.Requery
Call FiltraSottomaschera
End Sub
On the After Update event of cboSceltaTipo and chkCatEmmeti I inserted this code:
Private Sub cboSceltaTipo_AfterUpdate()
Call FiltraSottomaschera
End Sub
Private Sub chkCatEmmeti_AfterUpdate()
Call FiltraSottomaschera
End Sub
In the header of the form I inserted this code:
Private Sub FilterSubMask()
Dim filter As String
filter = ""
' Filter by SubCategories
If Not IsNull(Me.cboChoiceSubCategories) Then
filter = filter & "IDSubCategories = " & Me.cboChoiceSubCategories & " AND "
End If
' Filter by Product Type
If Not IsNull(Me.cboChoiceType) Then
filter = filter & "IDTypeProduct = " & Me.cboChoiceType & " AND "
End If
' Filter by Checkbox
If Me.chkCatEmmeti = True Then
filter = filter & "CatEmmeti = True AND "
End If
' Remove the last " AND " if present
If filter <> "" Then
filter = Left(filter, Len(filter) - 5)
End If
' Apply the filter to the subform
Me.Filter = filter
Me.FilterOn = (filter <> "")
End Sub
The filter does not work, in the sense that the second combo box (cboSceltaTipo) does not filter and in the subform all the values filtered by the first box cboSceltaSottoCategorie are returned. Where am I going wrong?
Thanks