I'm rather stuck on a report filter and recordset. Code below results in a dialog on 1st round, the name of the 1st client. No matter what I type in, the report saves but is empty
2nd round of loop returns rtError3075 when assessing DoCmd.OpenReport section. Any support most appreciated 


Code:
Dim rst As DAO.Recordset
Dim FOLDERPATH, FOLDER, FILEMONTH, FILENAME As String
Dim FILEYEAR As Integer
Dim REPORTOBJECT As REPORT
Dim ReportClient As String
Set rst = CurrentDb.OpenRecordset("SELECT DistinctClientName FROM tmpFilteredClients", dbOpenSnapshot)
' make sure that we have data
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
Const REPORT_NAME As String = "rptClientActionReport"
' open the report setting the where parameter
DoCmd.OpenReport REPORT_NAME, acViewPreview, , _
"[Reports]![rptClientActionReport]![Group of ClientName] = " & rst![DistinctClientName], _
acWindowNormal
Set REPORTOBJECT = Reports![rptClientActionReport]
'Settings for saving report
FOLDERPATH = DLookup("FolderPath", "tblLIBSaveTo")
FOLDER = Forms!frmClientReports!cboMonth
FILEMONTH = Forms!frmClientReports!cboMonth
FILEYEAR = Forms!frmClientReports!!txtYearSuffix
FILENAME = FOLDERPATH & "" & FOLDER & "" & "ClientReports_" & FILEMONTH & "20" & FILEYEAR & ".pdf"
' save the opened report
DoCmd.OutputTo acOutputReport, REPORT_NAME, acFormatPDF, FILENAME
DoCmd.OutputTo acOutputReport, "rptClientActionReport", acFormatPDF, FILENAME
' close the report
DoCmd.Close acReport, REPORT_NAME
DoEvents
rst.MoveNext
Loop
End If ' rst.RecordCount > 0
rst.Close
Set rst = Nothing
Attachments
Last edited by a moderator: