Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Macros _ Generating Pdf Files

Posted by: as2solutions Jul 18 2019, 01:41 PM

I'm using a macro (ExportWithFormatting) to generate a pdf from an existing report. I am currently leaving the "Output File" empty so that the user is prompted to key in the output location and file name.

What I am hoping to accomplish is to feed the output location and file name for the PDF from a table, which contains both the output location and file name, therefore removing the manual step of prompting the user.

Any ideas??

Posted by: MadPiet Jul 18 2019, 01:42 PM

use VBA and a loop to pass the parameter/filter values to the report, then output

Posted by: theDBguy Jul 18 2019, 01:54 PM

If you want to keep using a macro, you could try using the SearchForRecord action and store the information in a LocalVar.

Posted by: as2solutions Jul 18 2019, 02:00 PM

Do either of you have any example db's. I am not advanced enough in my programming abilities.

Posted by: theDBguy Jul 18 2019, 02:06 PM

Hi. It might be simpler if you could post a sample db we could modify for you. This way, whatever we do, we can be somewhat certain will apply to your specific situation, and you won't have to "interpret" what we did, trying to apply it to your own db.

Posted by: as2solutions Jul 18 2019, 06:00 PM

Thanks everyone! I poked around and found some code that works great. All I had to do was tweak it a little bit.

DoCmd.OutputTo acOutputReport, "rptSales_Detailedit_Offlinewithout_AutoPDF", _
acFormatPDF, "C:\PDFS\" & [filename] & " - " & [filenumber] & ".pdf"

Posted by: MadPiet Jul 18 2019, 06:22 PM

I thought instead of this:

QUOTE
What I am hoping to accomplish is to feed the output location and file name for the PDF from a table, which contains both the output location and file name, therefore removing the manual step of prompting the user.


you were going to loop through a table to get the filter values "[FieldName]='" & rs.Fields("MyFieldName") & "'"

Guess not, though. If you have to do that, let us know. It's pretty simple if you know how to play with recordsets.

Posted by: theDBguy Jul 18 2019, 10:25 PM

Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.