DoCmd.OutputTo (Access)

The OutputTo method carries out the OutputTo action in Visual Basic.

You can use the OutputTo method to output the data in the specified Access database object (a datasheet, form, report, module, data access page) to several output formats. 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 acFormatASP for the OutputFormat argument, you must specify acOutputTable, acOutputQuery, or acOutputForm for the ObjectType argument. The Access data is output in the selected format and can be read by any application that uses the same format. For example, you can output an Access report with its formatting to a rich-text format document and then open the document in Microsoft Word.

OutputTo (ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, OutputQuality)


DoCmd.OutputTo acOutputTable, "Employees", _ 
 acFormatRTF, "Employee.rtf", True

Arguments

The following argument is required

ObjectType (AcOutputObjectType) - An AcOutputObjectType constant that specifies the type of object to output.

Here you can find possible values for AcOutputObjectType

Optional arguments

The following arguments are optional

ObjectName (String) - 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 Office Access searches for the object with this name first in the library database, and then in the current database.

OutputFormat (Integer) - An AcFormat constant that specifies the output format. If you omit this argument, Access prompts you for the output format.

OutputFile (String) - A string expression that's the full name, including the path, of the file that you want to output the object to. If you leave this argument blank, Access prompts you for an output file name.

AutoStart (Boolean) - 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 (String) - A string expression that's the full name, including the path, of the file that you want to use as a template for an HTML, HTX, or ASP file.

Encoding (String) - The type of character encoding format that you want used to output the text or HTML data. You can select MS-DOS, Unicode, or Unicode (UTF-8). The MS-DOS argument setting is available only for text files. If you leave this argument blank, Access outputs the data by using the Windows default encoding for text files and the default system encoding for HTML files.

OutputQuality (AcExportQuality) - An AcExportQuality constant that specifies the type of output device to optimize for. The default value is acExportQualityPrint.

Possible return values are acExportQualityPrint - The output is optimized for printing, acExportQualityScreen - The output is optimized for onscreen display.