Export Report as csv format?

G

GEORGIA

is it possible to export report as csv format?

I've used output format as text but the file does not line up right.

My code loooks something like this.
DoCmd.OutputTo acOutputReport, "TEST_file", "Text Files
(*.txt;*.csv;*.tab;*.asc)", "C:\MyDocuments\test_" & Format(Date, "MMDDYYYY")
& ".csv"

I've used output format as Excel, however, the file may look csv file but it
is not.
File does need to be csv format or the program we use fails.

Thanks!
 
M

Marshall Barton

GEORGIA said:
is it possible to export report as csv format?

I've used output format as text but the file does not line up right.

My code loooks something like this.
DoCmd.OutputTo acOutputReport, "TEST_file", "Text Files
(*.txt;*.csv;*.tab;*.asc)", "C:\MyDocuments\test_" & Format(Date, "MMDDYYYY")
& ".csv"

I've used output format as Excel, however, the file may look csv file but it
is not.
File does need to be csv format or the program we use fails.


No way. A report is a graphic data presentation. They
won't even look good when printed to a text only printer,

Most needs are met by just exporting the report's record
source query. If that's not sufficent, then I suggest that
you write a procedure using the file I/O
statements/functions Open, Print, etc.
 
G

GEORGIA

I wish I can use the query to export it but I have to use the report.

Not familiar with I/O statements/functions, could you guide me?

Thanks again
 
M

Marshall Barton

Well, you can't use the report so you need to find another
way. Since a report is a formatted version of its record
source query, the query is the most logical place to start.

Using the file I/O statements/functions can be anywhere from
very simple to extremely complex depending on your
programming experience and how you want the resulting text
file to look.

If you want to try using File I/O, check VBA Help for:
Open Statement
FreeFile
Print # Statement
Close Statement
Spc Function
Tab Function

Then ask specific questions about how you can achive a
particular effect.
 
C

Chuck

is it possible to export report as csv format?

I've used output format as text but the file does not line up right.

My code loooks something like this.
DoCmd.OutputTo acOutputReport, "TEST_file", "Text Files
(*.txt;*.csv;*.tab;*.asc)", "C:\MyDocuments\test_" & Format(Date, "MMDDYYYY")
& ".csv"

I've used output format as Excel, however, the file may look csv file but it
is not.
File does need to be csv format or the program we use fails.

Thanks!

If you save it as an Excel file, you can open it in Excel and from there
re-save it as a CSV file.

Do not work with the report. Open the query your report is based on. Click
on: File, Save AS/Export. Select export to an external file or data base.
Fill in the required data for file name and file location. Set file type to
..csv

The saved file will open in Word with " " around all the fields and a ,
between the fields: "field1", "field2" ...

The saved file will also open in Excel and the data between the " " will be in
cells without the " ".

If you automate this process with a macro, include the Format(Date,
"MMDDYYYY") inside the quotes for the file name.

I would use Format(Date, "MMDDYYYY")
{ or even Format(Now, "YYYYMMDD HH:NN AM/PM"}
because a specific file is easier to find in a list of files.

Chuck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top