I have a control table with various reports that I want to output to PDF. In Access 2007, I wrote a Do While Loop to go through the local table (30 records) and print out each report. The problem is that it just prints out the same report 30 times. Can anyone tell me what is wrong with this code? I have used the Do While Loop for similar purposes many times. This is the first time I have encountered this error. I am very frustrated and would appreciate some advice.
Code:
Sub mod_TestPrint()
On Error GoTo mod_TestPrint_Err
Dim dbs As DAO.Database, rst As DAO.Recordset, StrRptName As String, strPath As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblEmailControlPrc", dbOpenTable, dbReadOnly)
StrRptName = rst!ReportName
strPath = rst!FilePath & Format(Date, "mmmm") & rst!FileName
rst.MoveLast
rst.MoveFirst
Do While Not rst.EOF
DoCmd.OutputTo acOutputReport, StrRptName, "PDFFormat(*.pdf)", strPath, False, "", 0, acExportQualityPrint
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
MsgBox Prompt:="Pricing Reports have been saved to pdf."
mod_TestPrint_Exit:
Exit Sub
mod_TestPrint_Err:
MsgBox Error$
Resume mod_TestPrint_Exit
End Sub