Format Date Via Code

geraldcor

Registered User.
Local time
Today, 13:53
Joined
Jan 26, 2004
Messages
145
Hello All,
I have a nifty automatic pdf printing scheme set up using pdf995. I use criteria from the reports themselves to name the output files for the pdf. On one of the reports they want the date to be a part of the filename. When I try to base it on a date field on a form (the form where the reports are being printed from) the print to pdf fails because the date format is 05/11/2006. I cannot have the slashes in the filename. I formated the textbox with the date to dd mmm yyyy so it shows up formatted correctly but I gues when it is pulling the info for the pdf it pulls the standard slash format thus the pdf will not print. So, how can I make it so access or better yet pdf995 recognizes the date in a filename friendly format? VBA, or other? Thank you all for your help.

Greg
 
Can you convert the date to a string before you use it?
 
Yes I can do that, then how do I format it properly? I tried just making it a string and then making that string = to the date textbox. That didn't work of course.
 
Hum... Did you format it before you converted it?
 
I am just formating it on the form in the properties, then converting it when the user clicks a command button to print to pdf.
 
Are you naming the file in a pc of code somewhere?
 
pc of code?
The format is
Call PrintPDFStatements(stDocName1, "IDFL Statement " & dateformat)
PrintPDFStatements in a module that creates a folder if one doesn't exist and makes sure the criteria is the same then it calls another portion of the module that does the actual printing. stDocName1 is the report name in access and the stuff followint the "," is the filename.
 
Does 'dateformat' contain the date you need to use?
 
So can you convert it to a string there? (fyi:Not so good a name for a variable:))
 
Here is what I did and it works wonderfully (I tried a bunch of different ways to format the date and this is the one that the users liked)
Call PrintPDFStatements(stDocName3, "IDFL Statement " & Format$(stdateformat, "mm-dd-yy"))
It ends up being formated as 05-11-06. Thanks for your help Ken, this isn't the first time.

Greg
 

Users who are viewing this thread

Back
Top Bottom