Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2015-02-12
6
Medium Priority
?
171 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 74

Expert Comment

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

Accepted Solution

by:
Wilder1626 earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

810 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