Hi,
I have a report , which i print every month and it consist of of more than 500 pages. This report is based on a Query called L_Inv2. i want to filter and loop this report based on the filed AccountReference with in the query. And save as PDF for individual accounts.
i have also created another query based on the L_Inv2, Called L_Inv4 which only got the record of account numbers as a AccountReference
i am trying to use below code but some how this is not working.
Can some one please help me.
Please note i am using Access 2013.
Regards
Farhan
I have a report , which i print every month and it consist of of more than 500 pages. This report is based on a Query called L_Inv2. i want to filter and loop this report based on the filed AccountReference with in the query. And save as PDF for individual accounts.
i have also created another query based on the L_Inv2, Called L_Inv4 which only got the record of account numbers as a AccountReference
i am trying to use below code but some how this is not working.
Code:
Private Sub Command43_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
Dim filterDefintion As String
Dim filename As String
strSQL = "Select AccountReference FROM L_Inv4"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do While rs.EOF = False
filterDefinition = "[AccountReference] = " & rs![AccountReference]
filename = rs![CompanyName] & rs![AccountReference]
filename = Replace(filename, "/", "-")
DoCmd.OpenReport "L_Inv2", acViewReport, "qryReportInfo", filterDefinition, acNormal
DoCmd.OutputTo acOutputReport, "L_Inv2", "PDFFormat(*.pdf)", "C\PROJECTS\" & filename & ".pdf", False, "", , acExportQualityPrint
DoCmd.Close acReport, "L_Inv2"
rs.MoveNext
Loop
End Sub
Can some one please help me.
Please note i am using Access 2013.
Regards
Farhan
Last edited by a moderator: