All; using 2010; I have the following code snippet. I am creating the output for report#1. It works. Now I want to output report#2 based on criteria in qryMarkNames. Ex. If letter_code is New I need Report 1 else report 2. CustID is in all my queries through the db. I am doing something wrong because its throwing errors like missing brackets and such. The query I’m trying to reference that has the field I need to criteria is on a different form. I am also using a different query for the reports. What do I need to do differently? Can someone assist please.
Code:
' Set current CustID (used by the reports' underlying queries).
g_varCurrentCustID = !client_id
' If CurrentDb().QueryDefs("[qryMarkNames]).[letter_code]" = "New" Then
' Create the report #1.
strPathAndFilename_Report1 = strPathToStatementFiles & strReportFilenamePrefix & strScrubbedBrokerName & " " & strState & " " & varCheckIssueDate & ".pdf"
DoCmd.OutputTo acOutputReport, "rptLetterNEW", acFormatPDF, strPathAndFilename_Report1, False
DoEvents ' Allow this operation to be fully completed before proceeding.
Else
' Create the report #2.
strPathAndFilename_Report2 = strPathToStatementFiles & strReportFilenamePrefix & strScrubbedBrokerName & " " & strState & " " & varCheckIssueDate & ".pdf"
DoCmd.OutputTo acOutputReport, "rptLetterTrueUp", acFormatPDF, strPathAndFilename_Report1, False
DoEvents ' Allow this operation to be fully completed before proceeding.
Endif