Solved

Apprnding a date to Access OutputTo statement

Posted on 2011-09-27
3
402 Views
Last Modified: 2013-11-27
I have a form with a list box (lstReports) to select reports for various outputs email as PDF or Excel, print, View, and Save to PDF. All work fine except on the save to PDF, I want to append the current date to the end of the filename but it is failing with “the OutPutTo action was canceled” error.  If I exclude the append operation it save fine with the report name.
Private Sub btnSavePDF_Click()
On Error GoTo btnSavePDF_Click_Err
Dim stDocName2 As String

stDocName2 = Me.lstReports

    DoCmd.OutputTo acOutputReport, stDocName2, acFormatPDF, stDocName2 & Format(Date, mmddyyyy), True


btnSavePDF_Click_Exit:
    Exit Sub

btnSavePDF_Click_Err:
    MsgBox Error$
    Resume btnSavePDF_Click_Exit
End Sub

Open in new window

0
Comment
Question by:skull52
3 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 36712905
Try this:

DoCmd.OutputTo acOutputReport, stDocName2, acFormatPDF, _
    stDocName2 & Format(Date, "mmddyyyy") & ".pdf", True

Open in new window



BTW, I recommend using yyyy-mm-dd (or yyyymmdd) instead: that way, your files will sort "chronologically" in your directory.
0
 

Author Comment

by:skull52
ID: 36713016
Thanks Matt that worked I was so close. The only issue I now have is how do I select where to save it?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question