Solved

Apprnding a date to Access OutputTo statement

Posted on 2011-09-27
3
376 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

762 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now