Link to home
Start Free TrialLog in
Avatar of Derek Rice
Derek Rice

asked on

ExportWithFormatting from Access

I have built 4 reports in Access as part of an Attendance Tracking Database. The reports are all built in a similar fashion with VBA code in the event on open of the report that populate some textboxes. I have also added a button on the report that brings up the built in macro "ExportWithFormatting" to allow the user to save the report as a PDF,

For 3 of the reports when the file is exported to PDF all of the fields populated by VBA code are saved but on the last report when it is saved to PDF the fields which were populated by the VBA code appear blank in the saved version. I am losing my mind as I built them all the same but am getting a different outcome.

Does anyone know why these fields are saving blank to the PDF?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Does anyone know why these fields are saving blank to the PDF?
do you have a sample database can upload here?

why don't you export your data as a report, in which you can format it, and when necessary, we can export it to PDF ?
Avatar of Derek Rice
Derek Rice

ASKER

I am thinking it might have something to do with the built in macro and what it is actually doing.

As mentioned there is code in the on load event of the report that populates the fields based on other fields from forms. This allows the report to display the fields correctly.

The save as PDF button which just runs the built in macro Export With Formatting is on the report footer so it can only be clicked when the report is already open.

My thought is that the Export With Formatting ignores the fact the report has already been opened/loaded and just exports as if the form were closed ie not running the VBA to populate the fields.

Is there a good way around this?

Perhaps VBA code that directly exports to PDF? With that option does the user still have the option to choose where they want to save it and name it?
try to place the Button to export the report in the form.
you can use this command to export the report to pdf

DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, "c:\Folder\" & rptName & ".pdf"
how do you call the macro ExportWithFormatting ? do you have codes or database can share with us here?
ASKER CERTIFIED SOLUTION
Avatar of Derek Rice
Derek Rice

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This was an error in my programming which I identified and corrected.