Hi
I am using the code below to produce individual valuation reports for each policy, rptVALBATCH.
To limit the number of reports produced in one go, there is a parameter query hard coded on the policy number field in the report query of Policy Number, Between "CL10000074" And "CL10000354" whihc works fine but I must open the query each time to run a new batch of reports.
I tried changing the parameters to Between [Policy Number From:] And [PolicyNumber To:] on the query and now get the error message
Run-time error 3061 Too few parameters.Expected 2
I have searched and think this shoul dbe done with the button code below by adding in -
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Can anyone help me with this ?
Thanks
in advance for any help
Fi
-------------------------------------------------------------------------------------
Private Sub cmdVALBATCH_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyFilename As String
Dim MyPath As String
Dim temp As String
MyPath = "Z:\USERNAME\ Weekly Reports\December 2017 Valuations\IH\Jurisdiction"
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT distinct [Policy No]FROM [qryVALBATCH]", dbOpenSnapshot)
Do While Not rs1.EOF
temp = rs1("PolicyNo")
MyFilename = rs1("PolicyNo") & ".PDF"
DoCmd.OpenReport "rptVALBATCH", acViewReport, , "[PolicyNo]='" & temp & "'"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename
DoCmd.Close acReport, "rptVALBATCH"
DoEvents
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
Set db = Nothing
End Sub
I am using the code below to produce individual valuation reports for each policy, rptVALBATCH.
To limit the number of reports produced in one go, there is a parameter query hard coded on the policy number field in the report query of Policy Number, Between "CL10000074" And "CL10000354" whihc works fine but I must open the query each time to run a new batch of reports.
I tried changing the parameters to Between [Policy Number From:] And [PolicyNumber To:] on the query and now get the error message
Run-time error 3061 Too few parameters.Expected 2
I have searched and think this shoul dbe done with the button code below by adding in -
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Can anyone help me with this ?
Thanks

Fi
-------------------------------------------------------------------------------------
Private Sub cmdVALBATCH_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyFilename As String
Dim MyPath As String
Dim temp As String
MyPath = "Z:\USERNAME\ Weekly Reports\December 2017 Valuations\IH\Jurisdiction"
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT distinct [Policy No]FROM [qryVALBATCH]", dbOpenSnapshot)
Do While Not rs1.EOF
temp = rs1("PolicyNo")
MyFilename = rs1("PolicyNo") & ".PDF"
DoCmd.OpenReport "rptVALBATCH", acViewReport, , "[PolicyNo]='" & temp & "'"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename
DoCmd.Close acReport, "rptVALBATCH"
DoEvents
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
Set db = Nothing
End Sub