[AccessD] CSV export

Gary Kjos garykjos at gmail.com
Wed Nov 29 09:43:15 CST 2006


According to the Access 97 help you would use the Output To method of
the DoCmd Object.

Something like

DoCmd.OutputTo acOutputReport, "rptKeithsReport", acFormatTXT,
"C:\WORK\KeithsReportOutput.CSV", True

I'm thinking you will be getting less than satisfactory results though
if my experience exporting reports to Excel format from Access is any
indication. I think you would do well to clone the query and introduce
the logical stuff the report does to come up with any fields that
don't exist in the orginal query. With reports exported directly to
Excel I always get lots of extraneous columns.

Good luck.

GK

Here's more info on the Output To;
-------------------------------------------------------
The OutputTo method carries out the OutputTo action in Visual Basic.
For more information on how the action and its arguments work, see the
action topic.

Syntax

DoCmd.OutputTo objecttype[, objectname][, outputformat][,
outputfile][, autostart][, templatefile]

The OutputTo method has the following arguments.

Argument	Description

objecttype	One of the following intrinsic constants:
acOutputForm
acOutputModule
acOutputQuery
acOutputReport
acOutputTable
objectname	A string expression that's the valid name of an object of
the type selected by the objecttype argument. If you want to output
the active object, specify the object's type for the objecttype
argument and leave this argument blank.
If you run Visual Basic code containing the OutputTo method in a
library database, Microsoft Access looks for the object with this name
first in the library database, then in the current database.
outputformat	One of the following intrinsic constants:
acFormatActiveXServer
acFormatHTML
acFormatIIS
acFormatRTF
acFormatTXT
acFormatXLS
If you leave this argument blank, Microsoft Access prompts you for the
output format.
outputfile	A string expression that's the full name, including the
path, of the file you want to output the object to.
If you leave this argument blank, Microsoft Access prompts you for an
output file name.
autostart	Use True (–1) to start the appropriate Microsoft
Windows–based application immediately, with the file specified by the
outputfile argument loaded. Use False (0) if you don't want to start
the application. This argument is ignored for Microsoft Internet
Information Server (.htx, .idc) files and Microsoft ActiveX Server
(*.asp) files.
If you leave this argument blank, the default (False) is assumed.
templatefile	A string expression that's the full name, including the
path, of the file you want to use as a template for an HTML, HTX, or
ASP file.
Remarks

Modules can be output only in MS-DOS Text format, so if you specify
acOutputModule for the objecttype argument, you must specify
acFormatTXT for the outputformat argument. Microsoft Internet
Information Server and Microsoft ActiveX Server formats are available
only for tables, queries, and forms, so if you specify acFormatIIS or
acFormatActiveXServer for the outputformat argument, you must specify
acOutputTable, acOutputQuery, or acOutputForm for the objecttype
argument.

You can leave an optional argument blank in the middle of the syntax,
but you must include the argument's comma. If you leave a trailing
argument blank, don't use a comma following the last argument you
specify.

-- 
Gary Kjos
garykjos at gmail.com



More information about the AccessD mailing list