I have code for outputting an Access report into multiple PDF's, but I am having trouble with the filtering.
The code below does create multiple pdf files but it doesn't filter the results. All pages show up each report. When I switch the OpenReport method to acViewPreview to test, it correctly displays only the pages it should in preview.
Can anyone tell what I am doing wrong?
The two report methods:
DoCmd.OpenRepor t strRptNm, acViewNormal, , "ProviderNa me = '" & ProviderNm & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
The entire code:
The code below does create multiple pdf files but it doesn't filter the results. All pages show up each report. When I switch the OpenReport method to acViewPreview to test, it correctly displays only the pages it should in preview.
Can anyone tell what I am doing wrong?
The two report methods:
DoCmd.OpenRepor t strRptNm, acViewNormal, , "ProviderNa me = '" & ProviderNm & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
The entire code:
Code:
Dim ProviderNm As String Dim PathNm As String Dim RptNm As String Dim strFileNm As String Dim Sql As String Dim db As Database Dim rs As Recordset strPathNm = "C:\RVU\" strRptNm = "rptProvider" Sql = "SELECT DISTINCT ProviderName FROM qryProvider" Set db = CurrentDb Set rs = db.OpenRecordset(Sql) Do Until rs.EOF ProviderNm = rs!ProviderName strFileNm = strPathNm & ProviderNm & "\Productivity\" & "2011-08" & ".pdf" DoCmd.OpenReport strRptNm, acViewNormal, , "ProviderName = '" & ProviderNm & "' " DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm DoCmd.Close acReport, strRptNm rs.MoveNext Loop rs.Close Set rs = Nothing Set db = Nothing
Comment