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.
 
S

Stephen Lebans

See:
ACC: Error Message Using OutputTo to Output a Report to Another Format

http://support.microsoft.com/kb/226526/en-us
SYMPTOMS
When you use the OutputTo action or method to output a report to another
format, you receive one of the following errors:
Run-time error '2024':

The report snapshot was not created because you do not have enough free disk
space for temporary work files.
-or-
Run-time error '2302':

Microsoft Access can't save the output data to the file you've selected.
-or-
Run-time error '2282':

The formats that enable you to output data as a Microsoft Excel, rich-text
format, MS-DOS text, or HTML file are missing from the Windows Registry.
Back to the top

CAUSE
You may receive one of the errors that is mentioned in the "Symptoms"
section if any one of the following is true of the OutputFile argument of
the OutputTo action or method: . You did not specify a file name.

-or-
. The file name that you supplied contains an invalid character
(!@#$%^&*():;).

-or-
. The path that you specify does not exist.

Back to the top

RESOLUTION
To work around this problem, do the following: . Modify the OutputFile
argument of the OutputTo action or method to include a file name.
. Make sure that the file name does not include any invalid
characters.
. Make sure that you are using the correct path.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
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