I am getting the following error when executing the code below. Any idea what I'm doing wrong? The query uses a start and end date field from the calling form. Is this the issue perhaps??
Thanks for the help.....
Private Sub Command65_Click()
'Print to pdf 1099 Statements for all advisors with activity
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = CurrentDb.OpenRecordset("SELECT [Rep] FROM [1099 Details Query]")
Do Until rst.EOF
'View and Save the report as a pdf
DoCmd.OpenReport "[1099 Details Report]", acViewPreview, , "Rep=" & rst!Rep, acHidden
DoCmd.OutputTo acOutputReport, "[1099 Details Report]", acFormatPDF, "J:\1099 Reports\" & rst!Rep & "1099 Details 2012.pdf"
DoCmd.Close acReport, "1099 Details Report"
Set rst = Nothing