Solved

Export file to desktop with today's date added to the end of the file name

Posted on 2015-02-12
6
141 Views
Last Modified: 2015-02-13
I'm using this code to attempt to export a file to the user's desktop WITH today's date in the file name.  Like:

Mail List 02-12-02015.csv

but it isn't working.

Here's my line of code:

    DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & [txtToday] & ".csv"

which works fine until I add the   & [txtToday] &  to it.

What do I need to change the code to to make it work?
0
Comment
Question by:SteveL13
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40606977
Hi, Can you try like:

Format dd/mm/yyyy
 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"dd/mm/yyyy") & ".csv"

Open in new window


or

Format dd-mm-yyyy
 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"dd-mm-yyyy") & ".csv"

Open in new window


or

Format ddmmyyyy
 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"ddmmyyyy") & ".csv"

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40606997
Just a note here.

whenever you export files with the current data, you will be better to add the time as well, ...in case more than one file is for today
Also try to use the ISO date format so that the files will sort correctly in explorer.

"yyyy-mm-dd_hh-nn"
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40607025
The time stamp will be a good option unless you want to overwrite the file if it is exported multiple times on the same day.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40607041
,,,correct
;-)
0
 
LVL 11

Accepted Solution

by:
Wilder1626 earned 500 total points
ID: 40607054
So if you want the format Month - Day - Year, requested in your first post, it would be:
 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"mm-dd-yyyy") & ".csv"  

Open in new window


and with the time stamp added to the format Month - Day - Year:
 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"mm-dd-yyyy_hh-nn") & ".csv"  

Open in new window

0
 

Author Closing Comment

by:SteveL13
ID: 40608009
Used:

 DoCmd.TransferText acExportDelim, , "qryExportMailList", strCSV & Environ("userProfile") & "\Desktop\" & "Mail List " & format(now,"mm-dd-yyyy_hh-nn") & ".csv"  


Thank you.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question