I'm building a simple tool to add a cover sheet to an existing PDF. The cover sheet is created by the user entering details in 3 fields in a form ([CandidateName], [Client], [Role]). This form shares the same underlying query "Ready4Report" as the Report "CoverSheet". The cover sheet is then exported to PDF and the merge then happens.
This works all fine but the underlying query & the report doesn't update itself prior to export. The code I'm using is below, can anyone help?
DoCmd.Save'create CoverPageDoCmd.OutputTo acOutputReport, "CoverSheet", "PDFFormat(*.pdf)", "C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\CoverPage.pdf", False, "", , acExportQualityPrint'Start of merge processDim FormattedCV As StringFormattedCV = "C:\Users\Digby Edwards\Desktop\CV Cruncher\CSCR " & Me.CandidateName & ".pdf"Dim CommandLine As StringDim CoverPage As StringDim CandidateCV As StringDim OutputDoc As StringDim OutputDoc4Move As String'Collates Docs for CommandLineCoverPage = """C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\CoverPage.pdf"""CandidateCV = """C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\OwnCV.pdf"""OutputDoc = """C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\OutputCV.pdf"""'Does the joiney bitCommandLine = """C:\Program Files\PDFtk Server\bin\pdftk.exe"" " & CoverPage & " " & CandidateCV & " cat output " & OutputDoc'MsgBox CommandLineCall Shell(CommandLine, vbNormalFocus)'Moves end Result to desired FolderOutputDoc4Move = "C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\OutputCV.pdf"FileCopy OutputDoc4Move, FormattedCV
A query is executed only when called, so there's no way to "refresh" that query - you just run it, and you'll get the most recent results.
If the query refers to other objects (like a Form), then it would use whatever values are on the form at the time, so there's no need to refresh the Form either.
You may need to change the point at which you open the report, of course - but you haven't shown us that. Remember too that you should open the report using acViewPreview - don't use acViewReport.
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
If the query refers to other objects (like a Form), then it would use whatever values are on the form at the time, so there's no need to refresh the Form either.
You may need to change the point at which you open the report, of course - but you haven't shown us that. Remember too that you should open the report using acViewPreview - don't use acViewReport.