I have a command button which when clicked, runs a VBA macro which saves a report to a PDF for the current record. The report is based on a predefined filter for based on the current ID field on the original form.
I have tried setting the criteria field to the current record of the form, setting a variable to the ID field. But the query is not getting the information to compare and the output of the report is all #Type and #Error.
When the macro is run, the query runs and prompts for the information the criteria is looking for.
How do I pass a variable from a form to a query in VBA?
Code:
Public Sub SaveFormToPDF_Click()
Dim CurrentID
CurrentID = [TaskSR]
MsgBox (CurrentID)
DoCmd.OutputTo acOutputReport, "rpt_Certificate", acFormatPDF, "..\Desktop\" & [FTSOCertNumber] & ".pdf"
End Sub