Avatar of Tom Crowfoot
Tom Crowfoot
Flag for United Kingdom of Great Britain and Northern Ireland asked on

refresh Query & form before Export

Dear Experts

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?


'create CoverPage
DoCmd.OutputTo acOutputReport, "CoverSheet", "PDFFormat(*.pdf)", "C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\CoverPage.pdf", False, "", , acExportQualityPrint

'Start of merge process
Dim FormattedCV As String
FormattedCV = "C:\Users\Digby Edwards\Desktop\CV Cruncher\CSCR " & Me.CandidateName & ".pdf"
Dim CommandLine As String
Dim CoverPage As String
Dim CandidateCV As String
Dim OutputDoc As String
Dim OutputDoc4Move As String

'Collates Docs for CommandLine
CoverPage = """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 bit
CommandLine = """C:\Program Files\PDFtk Server\bin\pdftk.exe"" " & CoverPage & " " & CandidateCV & " cat output " & OutputDoc

'MsgBox CommandLine
Call Shell(CommandLine, vbNormalFocus)

'Moves end Result to desired Folder
OutputDoc4Move = "C:\Users\Digby Edwards\Desktop\CV Cruncher\System Files\OutputCV.pdf"
FileCopy OutputDoc4Move, FormattedCV

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
Tom Crowfoot

8/22/2022 - Mon
Scott McDaniel (EE MVE )

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.
Dale Fye

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
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.
ask a question
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Tom Crowfoot

thanks for your help on this - the me.dirty trick works a treat
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck