Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outputting a TXT file with the date as the name 1

Status
Not open for further replies.

albyh

Technical User
May 10, 2003
32
GB
I am trying to output a text file from a report, I'm using the OutputTo command in a Macro. i need to know how set the date as the name of the text file being output.

Any help would be greatly appreciated.

Thanks

ALban
 
I've done this in a function, not in a macro:
Code:
Function Xferdoc_Stats()

Dim strFileName As String
strFileName = "c:\AccReports\Report\" & Format(Date - 1, "mm-dd-yyyy") & ".doc"
DoCmd.OutputTo acOutputReport, "rptStatsReport", acFormatRTF, strFileName
End Function
Then in your macro, invoke the RunCode action using the function name you specified....
 
I suggest a date format of "yyyymmdd" as this is better when looking at a lot of files...

Vince
 
You could use a field (possibly hidden) from an open form.

I use a macro with 'Transfer Text' and the 'File Name' set to="k:\" & [Forms]![frmMenu]![List10] & ".txt"

Where field list10 contains the name of the file.

 
The date format and date value shown in my example are simply a sample from one of my apps. The format was specified by a user who had "trouble" interpreting dates in any other format.......
 
This is great thanks a lot

Alban
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top