Solved

Apprnding a date to Access OutputTo statement

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

829 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