Exporting a report as .snp with Date Stamp in Title

W

Weniger

I am exporting a report to .snp format using the OutputTo action in a
macro, and I am trying to include a date stamp in the file name: for
example, "2006-08-02-<filename>.snp".

I have tried concatenating the string in the Output File field
["c:\...\" & format(now(),"yyyy-mm-dd") & "<filename.snp>"] but the
file is saved as the code itself "& format(now(),"yyyy-mm-dd")..."

If someone could help with this I would appreciate it.
 
W

Weniger

Here's what I got when converted the macro I was using to VBA (I am not
familiar with VBA).

<code>
Function export()
On Error GoTo export_Err

DoCmd.OutputTo acReport, "myTable", "SnapshotFormat(*.snp)", "h:\"
&Format(now(),"yyyy-mm-dd") & "descriptions.snp", False, "", 0


zz_export_Exit:
Exit Function

zz_export_Err:
MsgBox Error$
Resume export_Exit

End Function
</code>
 
D

Douglas J. Steele

Sorry, I missed the fact that you'd said macro.

That VBA looks correct. Does it work correctly when you run the function,
rather than your previous macro?
 
R

Rob

When I run it like I pasted it, it says I don't have enough free work
space for the creation of the snapshot. I tried rebooting my PC,
compacting and repairing the database, and deleting my recycling bin,
but still the same problem.

I tried it a second time with Excel rather than snapshot, and it said
it couldn't access the files for some reason...

But no, there's no difference from when I use it as a macro vs a
function.
 
R

Rob

When I run it like I pasted it, it says I don't have enough free work
space for the creation of the snapshot. I tried rebooting my PC,
compacting and repairing the database, and deleting my recycling bin,
but still the same problem.

I tried it a second time with Excel rather than snapshot, and it said
it couldn't access the files for some reason...

But no, there's no difference from when I use it as a macro vs a
function.
 
R

Rob

Nope. Both waysit says I don't have 'eough free disk space for the
temporary work files.' I deleted my recycling bin, rebooted, compacted
the database, and same story. I tried outputing to Excel, but it
wouldn't even recognize the file.
 
P

Pieter Wijnen

In short Replace
Format(now(),"yyyy-mm-dd")
with
Format(now(),"yyyy\-mm\-dd")
or simply
Format(now(),"yyyymmdd")

To avoid Access using regional settings to exchange (-) for your local date
seperator (/)

I'm not sure that is the case here, but I always use (\) if I need to
override output of regional settings date formats

Pieter
 
D

Douglas J. Steele

Good point, Pieter. I missed that, didn't I?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Pieter Wijnen"
 

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