M
M
I have copied some code from the Northwind sample database and amended it to
suit, but the code won't work for Case 3. Can anyone help?
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the SelectReports form.
Dim strWhereCategory As String
strWhereCategory = "Original Site Name =
Forms![SelectReport]!SelectSiteName"
Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "rptSite Details", PrintMode
Case 2
DoCmd.OpenReport "rptAll County Tasks", PrintMode
Case 3
If IsNull(Forms![SelectReport]!SelectSiteName) Then
DoCmd.OpenReport "rptAll County Tasks", PrintMode
Else
DoCmd.OpenReport "rptAll County Tasks", PrintMode, ,
strWhereCategory
End If
End Select
DoCmd.Close acForm, "frmSelectReport"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
The field "Original Site Name" and the source of SelectSiteName list box are
both text. The list box is unbound and the report is based on a query
grouped by Original Site Name.
Case 1 and 2 are OK (simple report) but this Case 3 using the WhereCategory
doesn't do anything. Any help appreciated.
suit, but the code won't work for Case 3. Can anyone help?
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the SelectReports form.
Dim strWhereCategory As String
strWhereCategory = "Original Site Name =
Forms![SelectReport]!SelectSiteName"
Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "rptSite Details", PrintMode
Case 2
DoCmd.OpenReport "rptAll County Tasks", PrintMode
Case 3
If IsNull(Forms![SelectReport]!SelectSiteName) Then
DoCmd.OpenReport "rptAll County Tasks", PrintMode
Else
DoCmd.OpenReport "rptAll County Tasks", PrintMode, ,
strWhereCategory
End If
End Select
DoCmd.Close acForm, "frmSelectReport"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
The field "Original Site Name" and the source of SelectSiteName list box are
both text. The list box is unbound and the report is based on a query
grouped by Original Site Name.
Case 1 and 2 are OK (simple report) but this Case 3 using the WhereCategory
doesn't do anything. Any help appreciated.