Adding date string to exported report files names

S

SteveB

Hi All

Access Version: 2007

I have a form which, through a number of command buttons, exports various
reports in pdf format. What I would like to do is prefix an exported report
with the date in YYYYMMDD format. As an example, the report in the code
below would be "20080822 Outstanding Requests.pdf". The other report I have
problems with the naming is how to put in the date and the record number
which is in field "Request_No" on the form it is generated from.

The code I have at the moment for one of the reports is;

Dim stDocName As String
stDocName = "rpt_notComplete"
DoCmd.OpenReport stDocName, acPreview, , , acHidden
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "Outstanding
Requests.pdf", True

As ever, any help or guidance would be gratefully received.

Regards

Steve

The code I have at the moment for one of the reports is;

Dim stDocName As String

stDocName = "rpt_notComplete"
DoCmd.OpenReport stDocName, acPreview, , , acHidden
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "Outstanding
Requests.pdf", True
 
F

fredg

Hi All

Access Version: 2007

I have a form which, through a number of command buttons, exports various
reports in pdf format. What I would like to do is prefix an exported report
with the date in YYYYMMDD format. As an example, the report in the code
below would be "20080822 Outstanding Requests.pdf". The other report I have
problems with the naming is how to put in the date and the record number
which is in field "Request_No" on the form it is generated from.

The code I have at the moment for one of the reports is;

Dim stDocName As String
stDocName = "rpt_notComplete"
DoCmd.OpenReport stDocName, acPreview, , , acHidden
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "Outstanding
Requests.pdf", True

As ever, any help or guidance would be gratefully received.

Regards

Steve

The code I have at the moment for one of the reports is;

Dim stDocName As String

stDocName = "rpt_notComplete"
DoCmd.OpenReport stDocName, acPreview, , , acHidden
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, "Outstanding
Requests.pdf", True

DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF,
Format(Date(),"yyyymmdd") & "Outstanding Requests.pdf", True

Though personally, I would find it better (more efficient) to add the
date after the text, i.e. "Outstanding Requests " &
Format(Date(),"yyyymmdd") & ".pdf"
 
S

SteveB

fredg said:
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF,
Format(Date(),"yyyymmdd") & "Outstanding Requests.pdf", True

Though personally, I would find it better (more efficient) to add the
date after the text, i.e. "Outstanding Requests " &
Format(Date(),"yyyymmdd") & ".pdf"

Hi Fred

Thanks for the very quick help, it really is much appreciated. The reason
the date string needs to go at the front is to comply with a corporate
filing system. Logic is that if the date is first everything can be sorted
in date order in a directory.

Many thanks

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top