Good evening everyone, as you see corresponding thread in Forms and Vba, your help has enabled me to filter a subform with 2 combined drop-down boxes and a checkbox and subsequently open a report. Now I would like to add a feature: if the checkbox is selected, clicking the button opens Report 1 (rptProductsFiltered), if it is not selected, clicking the button opens Report 2 (rptProductsFiltered_02). I modified the previous code (because in the db version of the other thread I was only opening one report) and inserted this:
Private Sub cmdApriReport_Click()
Dim strfiltro As String
strfiltro = "1=1"
If Not IsNull(Me.cboSceltaSottoCategorie) Then
strfiltro = strfiltro & " AND IDSottoCategorie = " & Me.cboSceltaSottoCategorie
End If
If Not IsNull(Me.cboSceltaTipo) Then
strfiltro = strfiltro & " AND IDTipoProdotto = " & Me.cboSceltaTipo
End If
If Me.chkCatEmmeti.Value = True Then
DoCmd.OpenReport "rptProdottiFiltrati_Attrezzature_Atletica_Emmeti", acViewPreview, , strfiltro
Else
DoCmd.OpenReport "rptProdottiFiltrati_Attrezzature_Atletica", acViewPreview, , strfiltro
End If
End Sub
At first it seemed to work, because but then I noticed that depending on whether the checkbox is selected or deselected one report opens or the other, however in both cases the items are not filtered (=they are all there, both those that have the checkbox selected and those that have it deselected). If you can suggest how to correct this, I would be grateful.
Private Sub cmdApriReport_Click()
Dim strfiltro As String
strfiltro = "1=1"
If Not IsNull(Me.cboSceltaSottoCategorie) Then
strfiltro = strfiltro & " AND IDSottoCategorie = " & Me.cboSceltaSottoCategorie
End If
If Not IsNull(Me.cboSceltaTipo) Then
strfiltro = strfiltro & " AND IDTipoProdotto = " & Me.cboSceltaTipo
End If
If Me.chkCatEmmeti.Value = True Then
DoCmd.OpenReport "rptProdottiFiltrati_Attrezzature_Atletica_Emmeti", acViewPreview, , strfiltro
Else
DoCmd.OpenReport "rptProdottiFiltrati_Attrezzature_Atletica", acViewPreview, , strfiltro
End If
End Sub
At first it seemed to work, because but then I noticed that depending on whether the checkbox is selected or deselected one report opens or the other, however in both cases the items are not filtered (=they are all there, both those that have the checkbox selected and those that have it deselected). If you can suggest how to correct this, I would be grateful.