save .snp file as system date and time

E

Emanuel Violante

Hi,

I'm trying to save a .SNP file in a specific directory and with the current
time and date.

The file is saved in the specified directory, but he's always saved as
today.snp

here is the code:

Dim stDocName As String
Dim today
today = Now

stDocName = "suporte_encomenda"
DoCmd.OutputTo acReport, stDocName, "Snapshot Format", "l:\docs\today.snp"

could anyone help me, please???

--
Thanks,

Sorry if my english isn''t correct, but I''m from Potugal ;)

Emanuel Violante Galeano
 
D

Dale Fye

First off, you didn't define a data type for your Today variable. I would
define it as a string.

Next, the Now() command returns a Date/Time value formatted as:
mm/dd/yyyy hh:mm:ss AM

I don't think Windows is going to like the slashes in the date or the colons
in the time. Personally, when I add a date/time stamp to my file names, I
like to use a format that I can easily sort ("yyyy-mm-dd_hh-nn-ss").

For another, your code is telling it to save it as "today.snp" as a literal
value rather than:

"I:\docs\" & Today & ".snp"

How about:

Dim strDoc as String
Dim FileName as String

FileName = "I:\docs\" & Format(Now, "yyyy-mm-dd-hh-nn-ss") & ".snp"

stDocName = "suporte_encomenda"
Docmd.outputto acreport, stDocName, "Snapshot Format", FileName

HTH
Dale
 
D

Douglas J. Steele

DoCmd.OutputTo acReport, stDocName, "Snapshot Format", "l:\docs\" &
Format(Now(), "yyyymmdd hhnnss") & ".snp"

That'll make the file something like 20080213 083910.snp. If you want it to
look like 2008-02-13 08-39-10.snp, you can use

"l:\docs\" & Format(Now(), "yyyy\-mm\-dd hh\-nn\-ss") & ".snp"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top