X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Add Month And Year To Pdf File Output Name, Access 2010    
post Nov 27 2019, 06:35 PM

Posts: 12
Joined: 12-October 19

I have upgraded to use the inbuild PDF printing function and use the following code to print out a PDF. There is a check button of the form from which the PDF is printed.

Private Sub cmdPrintStatement_Click()
If CheckPDF.Value = True Then
DoCmd.OpenReport "rpt229PDF", acViewPreview, , , acHidden
DoCmd.OutputTo acOutputReport, "rpt229PDF", acFormatPDF, "" & Company & ".pdf"
DoCmd.Close acReport, "rpt229PDF", acSaveNo
End If
If CheckPDF.Value = False Then
DoCmd.OpenReport "rpt229"
End If
End Sub

All works fine but whichever way I try, I cannot get a month and year to appear after the customers name. (there is a date field on the form,though it may be referable to use some form of Date() function. I always seem to have to many or not enough "" marks.

Any clues?

I dont need a file path as the software is on three different computers and have simple told the database to upload files to a new default folder at C:\V-Tech\PDF Documents
Go to the top of the page
post Nov 27 2019, 06:39 PM

Posts: 1,244
Joined: 25-January 16
From: The Great Land

Simply concatenate.

DoCmd.OutputTo acOutputReport, "rpt229PDF", acFormatPDF, Me.Company & "_" & Format(Date(), "yyyymm") & ".pdf"

This post has been edited by June7: Nov 27 2019, 06:43 PM

Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
post Nov 27 2019, 06:54 PM

Posts: 12
Joined: 12-October 19

Cheers works perfectly though I just changed yyyymm to mmyy. Next question, how to I get for the 11th month to print out Nov?
Go to the top of the page
tina t
post Nov 27 2019, 07:00 PM

Posts: 6,373
Joined: 11-November 10
From: SoCal, USA

well, generically,

Format(Date(), "mmmyy")

should do it. but if you only want the "short name" to be used when it's Nov, that takes a bit more work.


"the wheel never stops turning"
Go to the top of the page
post Nov 27 2019, 07:05 PM

Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA

Just the 11th month?.. Well, all months would display three-letter abbrevs with: Format(Date(), "MMMyyyy") if you want the first letter of the abbrev in uppercase.
This post has been edited by FrankRuperto: Nov 27 2019, 07:09 PM

Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
post Nov 27 2019, 07:16 PM

Posts: 12
Joined: 12-October 19

Absolutely brilliant. Changed to Date function to MMMyy and it works. I now get customername-NOV19.pdf as the file name.

Thank you all.
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    26th February 2020 - 06:11 AM