Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding date to end of filename

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I have code that emails a PDF to a distrobution list. Can someone take a look at the code below and tell me if there is a way i can modify it so it puts todays date on the end of the filename?

Code:
stdocname = "Thereport"

    DoCmd.SendObject acReport, stdocname, "pdf", "", cc1, bcc1, "test, "", True, """"

Can this be done here?

Thanks for any help!

Paul
 
hi,
Code:
dim dte as string

dte = Format(date, "yyyymmdd")


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip, would I then change ", stdocname" to ", stdocname & dte," ? If so, it does not appear to be giving me the desired results, I still only get the filename.pdf alone.
 
what's actually in dte?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip, I'm a bit confused, obviously i know, I need to add today's date to the end of "thereport". So when I email the report it would read "thereport20130926.pdf" instead of just "thereport.pdf". Not sure how to answer your question other than a date is in dte.

At this point it doesn't even need to be a date, I just need to understand how to add anything to the end of the filename. Everytime I do I get an error message that states the object cannot be found.

for example if i use
[coode]
DoCmd.SendObject acReport, stdocname & dte, "pdf",.....
[/code]

I get the error "cannot find the object 'thereport20130926'.

Thanks again for the help.

Paul

 
you must ALREADY have a file named 'thereport20130926'

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The second parameter of your SendObject call should be the name of the report.
You may put the date in the subject (7th arg) or the body (8th arg) of the message, eg:
DoCmd.SendObject acReport, stdocname, acFormatPDF, "", cc1, bcc1, stdocname & dte, "Please read " & stdocname & ".pdf", True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
[BLUE]stdocname = "Thereport"
tempstdocname = stdocname & Format(Now(), "yyyymmdd")
DoCmd.CopyObject , tempstdocname, acReport, stdocname
DoCmd.SendObject acReport, tempstdocname, "pdf", "", cc1, bcc1, "test", "", True, """"
DoCmd.DeleteObject acReport, tempstdocname[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top