Setting file name of report printed as PDF (1 Viewer)

Gkirkup

Registered User.
Local time
Today, 09:29
Joined
Mar 6, 2007
Messages
628
I have a report which must be printed as a PDF. I have set the printer default of the report to PDF, which works fine.
I need to have the report PDF name be unique, so that previous copies are not overwritten. I do this by setting the Me.Caption property in the report's On Open area as Me.Caption = "MyName "&Cstr(Now()).
That works fine when I run the report manually, the PDF name includes the date and time. But when I run the report from a command button on a form, the PDF file name is just the file name of the report "MyReportName".
To run the report from the command button I am using:
stDocName = "EODInventoryChangesLog"
DoCmd.OpenReport stDocName, acViewNormal
What am I doing wrong? I suspect that it's how I am calling the report, as when I run the report stand-alone it works fine.

Robert
 

HiTechCoach

Well-known member
Local time
Today, 11:29
Joined
Mar 6, 2006
Messages
4,357
I have a report which must be printed as a PDF. I have set the printer default of the report to PDF, which works fine.
I need to have the report PDF name be unique, so that previous copies are not overwritten. I do this by setting the Me.Caption property in the report's On Open area as Me.Caption = "MyName "&Cstr(Now()).
That works fine when I run the report manually, the PDF name includes the date and time. But when I run the report from a command button on a form, the PDF file name is just the file name of the report "MyReportName".
To run the report from the command button I am using:
stDocName = "EODInventoryChangesLog"
DoCmd.OpenReport stDocName, acViewNormal
What am I doing wrong? I suspect that it's how I am calling the report, as when I run the report stand-alone it works fine.

Robert


Robert,

Since it appears that previewing the report first make it work.

Try this:

Code:
stDocName = "EODInventoryChangesLog"
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.SelectObject acReport, stDocName, True
DoCmd.PrintOut acPrintAll
DoCmd.Close


Hope this helps ...
 

Gkirkup

Registered User.
Local time
Today, 09:29
Joined
Mar 6, 2007
Messages
628
Boyd: As they say here in California, "O M G !" That worked perfectly and was just what I needed. I learn something new every day here. Thanks!

Robert
 

Gkirkup

Registered User.
Local time
Today, 09:29
Joined
Mar 6, 2007
Messages
628
Boyd:
If you recall, you gave me the following great code to keep the file name of a PDF once set as the report's Me.Caption, and not have to use Preview.
stDocName = "EODInventoryChangesLog"
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.SelectObject acReport, stDocName, True
DoCmd.PrintOut acPrintAll
DoCmd.Close
That works great, except that the objects menu of Access appears on the screen, with the report name highlighted. Closing that menu closes down the application. Is there any way that the object menu can not be displayed, or can be removed?

Robert
 

mihdt007

New member
Local time
Today, 09:29
Joined
Apr 11, 2013
Messages
1
Hi

Thanks to your post, i looked for "docmd.printout", and i found something even better : docmd.outputto. With Access 2007 or higher, there's an option acFormatPDF that allows to generate directly a PDF file with our chosen name. You don't have to click "ok" for each generated file and you have different name for each file according to your own rule.
 

nonlinearly

Registered User.
Local time
Today, 09:29
Joined
Jun 13, 2012
Messages
21
unfortunately with OutputTo you do not have any way to configure pdf's options... for example if you want to embed the fonts to the exported pdf you are not in lucky!!!
I am looking for a solution that contains the dynamic naming of the files (without human intervention) but using the pdf printers to whom you can have predefined such parameters
 
Last edited:

Users who are viewing this thread

Top Bottom