Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2007

Tip: Looking for answers? Try searching our database.

Use Current Date on text file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sammy - 03 May 2007 08:02 GMT
I'm have a button on a form that will transfer text from a query to a text
file on my c:drive named "testfile05-01-07.txt"

I need to transfer text everyday, once a day.  I don't want to overwrite the
file each time.  Instead I want to create a new file each day with the above
name but the current date:  example testfile05-02-07, then on the next day a
new file should be named "testfile05-03-07", etc..

Here's my code to transfer to the text file:
DoCmd.TransferText acExportDelim, , "QryExport", "c:\temp\testfile05-01-07.
txt", True

Please help.  

Thanks,
Sammy
Scott McDaniel - 03 May 2007 11:11 GMT
>I'm have a button on a form that will transfer text from a query to a text
>file on my c:drive named "testfile05-01-07.txt"
[quoted text clipped - 3 lines]
>name but the current date:  example testfile05-02-07, then on the next day a
>new file should be named "testfile05-03-07", etc..

Try this:

DoCmd.TransferText acExportDelim, , "QryExport", "c:\temp\testfile" & Cstr(Date) & ".txt", True

If you do this more than once a day, of course, this would overwrite the existing file. If that's the case, you can use
Now instead of Date ... Now would stamp it with the Time and Date ...

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
Klatuu - 03 May 2007 14:47 GMT
Sammy, here is a suggestion for you.
Scott's answer is partially correct, but the problem is it will create a
file name like
c:\temp\testfile05\01\2007.txt
Which is probably not what you want.  There are issues with the \ in file
names.  In addition, to easily locate the file visually, I would suggest you
use a year, month, day format.  It will sort them in date order that way.  
Here is what I would use:

DoCmd.TransferText acExportDelim, , "QryExport", "c:\temp\testfile" &
Format(Date,"yy-mm-dd") & ".txt", True

Signature

Dave Hargis, Microsoft Access MVP

> I'm have a button on a form that will transfer text from a query to a text
> file on my c:drive named "testfile05-01-07.txt"
[quoted text clipped - 12 lines]
> Thanks,
> Sammy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.