I have 4 Parameters for the Report.
It can be run by
1st and 2nd with 4th (cmdAandB)
or
1st and 3rd with 4th (cmdAandB).
My code does not filter.
It worked with all 4 parameters selected.
Now when I am excluding one - something is busted.
Please, take a look.
Private Sub cmdRunReport_Click()
Dim strWhere As String
On Error GoTo ErrHandler
DoCmd.SetWarnings True
If Forms!Reports!cmbAB = "AandB" And Not IsNull(Forms!Reports!cmbR) Then
strWhere = "Name =" & Chr(34) & Forms!Reports!cmbN.Column(0) & Chr(34) & _
" And Region =" & Chr(34) & Forms!Offers_Hires_Reports!cmbR.Column(0) & Chr(34) '& _
DoCmd.OpenReport ReportName:="ReportAandB", View:=acViewPreview, WhereCondition:=strWhere
End If
If Forms!Reports!cmbAB = "AandB" And Not IsNull(Forms!Reports!cmbN) Then
strWhere = "Name =" & Chr(34) & Forms!Reports!cmbN.Column(0) & Chr(34) & _
" And Ofice =" & Chr(34) & Forms!Offers_Hires_Reports!cmbO.Column(0) & Chr(34) '& _
DoCmd.OpenReport ReportName:="ReportAandB", View:=acViewPreview, WhereCondition:=strWhere
End If
Exit Sub
ErrHandler:
If Err = 2501 Then
' Report canceled - ignore this
Else
MsgBox Err.DESCRIPTION, vbExclamation
End If
End Sub
It can be run by
1st and 2nd with 4th (cmdAandB)
or
1st and 3rd with 4th (cmdAandB).
My code does not filter.
It worked with all 4 parameters selected.
Now when I am excluding one - something is busted.
Please, take a look.
Private Sub cmdRunReport_Click()
Dim strWhere As String
On Error GoTo ErrHandler
DoCmd.SetWarnings True
If Forms!Reports!cmbAB = "AandB" And Not IsNull(Forms!Reports!cmbR) Then
strWhere = "Name =" & Chr(34) & Forms!Reports!cmbN.Column(0) & Chr(34) & _
" And Region =" & Chr(34) & Forms!Offers_Hires_Reports!cmbR.Column(0) & Chr(34) '& _
DoCmd.OpenReport ReportName:="ReportAandB", View:=acViewPreview, WhereCondition:=strWhere
End If
If Forms!Reports!cmbAB = "AandB" And Not IsNull(Forms!Reports!cmbN) Then
strWhere = "Name =" & Chr(34) & Forms!Reports!cmbN.Column(0) & Chr(34) & _
" And Ofice =" & Chr(34) & Forms!Offers_Hires_Reports!cmbO.Column(0) & Chr(34) '& _
DoCmd.OpenReport ReportName:="ReportAandB", View:=acViewPreview, WhereCondition:=strWhere
End If
Exit Sub
ErrHandler:
If Err = 2501 Then
' Report canceled - ignore this
Else
MsgBox Err.DESCRIPTION, vbExclamation
End If
End Sub