Trying to run a report from VBA. The query it uses asks for a parameter. I'm trying to pass the parameter into the query and getting a syntax error. The parameter/variable is set prior with a recordset number.
Here's the VBA code:
Dim lngInvoiceNumber As Long
lngInvoiceNumber = rs("tblRepat.Invoice_number")
DoCmd.OpenReport "InvOne", acViewNormal, qryOneInvoice, "[tblRepat.Invoice_number] = " & lngInvoiceNumber & ", , lngInvoiceNumber"
I get an error:
Syntax Error in (comma) in query expression '[tblRepat.Invoice_number] = 423,,lngInvoiceNumber
Using Access 2007
What I'm doing is:
Change the printer to pdf
Pulli a list of all invoices for the day
Looping thru the recordset and converting each invoice to a pdf.
The query for the report requires an invoice number.