report to destination as txt file

alkrm

Registered User.
Local time
Today, 18:10
Joined
Aug 13, 2003
Messages
39
hi ,
i need help with my code, am using this code to send a report as txt file to the desk top,

dim x as string
x="the report name"
docmd.OutPutTo acReport, x

with that code am going to the output window to choose the file format ,and then to another window to choose the destination"desktop for example" ,

Can any one tell me how to save the file to the desk top as txt file directly ??
 
like this?

DoCmd.OutputTo acOutputReport, "YourReportName", acFormatTXT, "C:\Windows\DeskTop\TestFile.txt", True

If you wanted to ensure you don't overwrite an existing file you can create the filename at run time and use this code to create a unique filename based on the date and time of export.

Code:
Dim tmpFile As String
tmpFile = "C:\Windows\DeskTop\Outputted" & Format(Date + Time, "yyyymmdd_hhnnss") & ".txt"
MsgBox tmpFile
DoCmd.OutputTo acOutputReport, "YourReport", acFormatTXT, tmpFile, True
 
Thanks for ur help,
and for the Great Idea of timming
 

Users who are viewing this thread

Back
Top Bottom