Hi,
I am trying to save the reports on disk using Query records. the program works well for all records but giving error when I type parameter in query design.
The below code working well for all records in query but not working when I set parameter in a query design for a field which linked with a form field.
The error" Too few parameters, expected 1"
any solution? or alternative?
I am trying to save the reports on disk using Query records. the program works well for all records but giving error when I type parameter in query design.
The below code working well for all records in query but not working when I set parameter in a query design for a field which linked with a form field.
The error" Too few parameters, expected 1"
any solution? or alternative?
Code:
Private Sub Command14_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyFileName As String
Dim mypath As String
Dim temp As String
mypath = "C:\gw\"
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT distinct [PayrollFor] FROM [qry_SalarySlipIndividual]", dbOpenSnapshot)
Do While Not rs.EOF
temp = rs("PayrollFor")
MyFileName = rs("PayrollFor") & ".PDF"
DoCmd.OpenReport "rpt_SalarySlipIndividual", acViewReport, , "[PayrollFor]='" & temp & "'"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, mypath & MyFileName
DoCmd.Close acReport, "rpt_SalarySlipIndividual"
DoEvents
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub