[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register 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
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

656 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