I have not been able to pass my OpenArg in my DoCmd.OpenReport VB script correctly. What I have opens all my records, and sends a complete report to each file record, when I want individual pdf's for each group of Service_Dealer_Loc that I have.
Here is what I am using:
Sub pst()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim str As String
str = "Select Service_Dealer_Loc From ptable"
Set db = CurrentDb
Set rs = db.OpenRecordset(str, dbOpenDynaset)
Do Until rs.EOF
stArg = "Service_Dealer_Loc = " & rs!Service_Dealer_Loc
DoCmd.OpenReport "preport", acViewPreview, , , , stArg
DoCmd.OutputTo acOutputReport, "preport", "*.pdf", "C:\Users\Documents\" & rs!Service_Dealer_Loc & ".pdf"
DoCmd.Close acReport, "preport"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
And here is the ON OPEN property of the report I am using:
Private Sub Report_Open(Cancel As Integer)
Dim strArg As String
strArg = Me.OpenArgs
Me.FilterOn = True
'MsgBox strArg
End Sub
Any suggestions are welcome
Here is what I am using:
Sub pst()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim str As String
str = "Select Service_Dealer_Loc From ptable"
Set db = CurrentDb
Set rs = db.OpenRecordset(str, dbOpenDynaset)
Do Until rs.EOF
stArg = "Service_Dealer_Loc = " & rs!Service_Dealer_Loc
DoCmd.OpenReport "preport", acViewPreview, , , , stArg
DoCmd.OutputTo acOutputReport, "preport", "*.pdf", "C:\Users\Documents\" & rs!Service_Dealer_Loc & ".pdf"
DoCmd.Close acReport, "preport"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
And here is the ON OPEN property of the report I am using:
Private Sub Report_Open(Cancel As Integer)
Dim strArg As String
strArg = Me.OpenArgs
Me.FilterOn = True
'MsgBox strArg
End Sub
Any suggestions are welcome