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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export report as txt file

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I have a report that I need to export to the txt file. What gives me an extra headache though is that I have to control the format of the output. The number of the blanks between the columns, number of the digits in the columns, etc.

I tried to modify the report so that it will come out in the format I need, but it still isn't what I want.

So I decided to write a code to control the format.

Here are the questions.
First, if anybody has done that before and could share the code, that be terrific
Second, if anybody knows the best ways to do that and wouldn't mind to give me some hints,I'd appreciate it a lot.

Thanks
 
Here's a start.

you can either use a Macro (OutputTo),
or you can use the module below.



Function OutputTo()
On Error GoTo OutputTo_Err

DoCmd.OutputTo acReport, "Customers", "MS-DOSText(*.txt)", "C:/Customers.txt", False, ""


OutputTo_Exit:
Exit Function

OutputTo_Err:
MsgBox Error$
Resume OutputTo_Exit

End Function



Replace "Customers" with the name of your report
and replace "C:/Customers.txt" with the full path and file name for the output of this method.

You could actually change the method so that it takes 2 arguments 1. the path, and 2. the output file name, which might make it easier to use especially if you have more than one report to tranfer.

Call the Function like this

Call OutputTo


Try this first, then we can talk about reformatting text.

David I'm Your Huckleberry!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top