By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

DoCmd.OutputTo - How can I add the date to my document name?

P: 94
I am exporting snaphot files on 1st of each month. I want each file i export to automatically insert the current date.

I have set the current date to a variable named DateTime and tried inserting this into my export string but it didn't like this... see below....

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", "Snapshot Format", "c:\my documents\siobhan\testsnapshot"&DateTime&".snp"
Anyone have any other suggestions???
Feb 12 '08 #1
Share this Question
Share on Google+
5 Replies


puppydogbuddy
Expert 100+
P: 1,923
I am exporting snaphot files on 1st of each month. I want each file i export to automatically insert the current date.

I have set the current date to a variable named DateTime and tried inserting this into my export string but it didn't like this... see below....

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", "Snapshot Format", "c:\my documents\siobhan\testsnapshot"&DateTime&".snp"
Anyone have any other suggestions???
Try this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatSNP, "c:\my documents\siobhan\testsnapshot" & CStr(DateTime) & ".snp", False
Feb 12 '08 #2

P: 94
It doesn't like it.....am getting a VB run-time error '2024'

"The report snapshot was not created because you don't have enough free disk space for temporary work files."

Yet when i run the simple....

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", "Snapshot Format", "c:\my documents\siobhan\Employer Funding Report (By Employer).snp"
....it works.

I am the administrator of mp PC and i have plenty of free disk space on my c: drive.

I'm confused.....help!!
Feb 12 '08 #3

puppydogbuddy
Expert 100+
P: 1,923
It doesn't like it.....am getting a VB run-time error '2024'

"The report snapshot was not created because you don't have enough free disk space for temporary work files."

Yet when i run the simple....

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", "Snapshot Format", "c:\my documents\siobhan\Employer Funding Report (By Employer).snp"
....it works.

I am the administrator of mp PC and i have plenty of free disk space on my c: drive.

I'm confused.....help!!
do you have all of these directories set up on your computer:
"c:\my documents\siobhan\testsnapshot"

Try not having so many.....eliminate >>>>>\testsnapshot
Feb 12 '08 #4

Expert Mod 2.5K+
P: 2,545
Appending the date directly or as a string will add the slash characters (e.g. 12/02/08 for UK dates formatted as today). These are illegal in the filename and will cause an error.

Use this format instead to append the date without the slash characters, year first then month then day: Format$(Date, "yymmdd")

Stewart
Feb 12 '08 #5

P: 94
Thanks!

As suggested the problem was in the format of the date. My fix was...

Expand|Select|Wrap|Line Numbers
  1. 'LOAD CURRENT DATE TO VARIABLE - IN FORMAT dd-mm-yyyy
  2. Date1 = Format(Date, "dd-mm-yyyy")
  3.  
  4. 'Save Report
  5. DoCmd.OutputTo acOutputReport, "Employer Funding Report (By Employer)", acFormatSNP, "c:\my documents\siobhan\Employer Funding Report (By Employer)" & Date1 & ".snp"
Feb 13 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.