Exporting Report to CSV Format

G

Guest

Hi
I have a report processed through a query, and need to export the data in
CSV format, I tried through a macro and then converted the Macro to VB, but
I am not able to get it to the desired csv format instead it output's in
excel format, code indicated below,
DoCmd.OutputTo acReport, "ARRANGEB", "MicrosoftExcelBiff8", "c:\ronytest.csv"
Please let me know how can amend the code to get the desired result.

Thanks
Ron
 
K

Ken Snell \(MVP\)

Check out the DoCmd.TransferText action in Help file (search on
TransferText). That is the better method to use in VBA for exporting a query
to a .csv file.
 
G

Guest

Hi Ken
I am trying to export a report and not a query, Query export is ok but not
report
Thanks
 
K

Ken Snell \(MVP\)

One does not actually export a report; one exports a report's RecordSource,
which is a query (even if the record source is a table, ACCESS builds a
query based on that table). So you can export the report's RecordSource
query.
 
G

Guest

Hi Ken
Reason I am exporting a report is , Group totals and sub group totals are
not possible through record source.

Thanks
 
K

Ken Snell \(MVP\)

OK -

Here is the syntax of the DoCmd.OutputTo method:

DoCmd.OutputTo ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart,
TemplateFile, Encoding


So I think your code line needs to be changed to this:

DoCmd.OutputTo acOutputReport, "ARRANGEB", acFormatTXT, "c:\ronytest.csv"
 

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