breezett93
Technical User
I have a query that pulls all records from a year provided by a user, qryIvcByYear. Then a report, IvcRpt, should be created for each record found. The report has a query in the record source to pull the relevant info related to the original record.
Instead, all records are being dumped into one report. My msgbox check confirms that a second report is never created.
Instead, all records are being dumped into one report. My msgbox check confirms that a second report is never created.
Code:
Dim dbs As Database
Dim rst As Recordset
Dim strSelect As String
Dim strYear As String
Dim strIvcId As String
Set dbs = CurrentDb
strYear = InputBox("Please enter the year of invoices to be archived.")
strSelect = ("SELECT* FROM qryIvcByYear WHERE Year([IvcDt]) = " & strYear & "")
'view recordset in query
Set rst = dbs.OpenRecordset(strSelect, dbOpenSnapshot)
If rst.EOF Then
Exit Sub
Else
rst.MoveFirst
Do Until rst.EOF
strIvcId = rst!IvcID
MsgBox (strIvcId)
DoCmd.OutputTo acOutputReport, "IvcRpt01", acFormatPDF, "ServerLocation\" & strYear & "\" & strIvcId & ".pdf"
rst.MoveNext
Loop
End If
rst.Close
Set dbs = Nothing