Solved

Exporting an Acces Report using VBA

Posted on 2003-12-12
5
1,414 Views
Last Modified: 2011-10-03
I'm writing an application in VBA that will produce various reports. For users, there are two options, either printing the report or viewing and editing the report. The first one is easy, the report is based on a table which I fil using sql. For the report to be edited, it needs to be exported to Word. How can I accomplish this from access?

I'm sure it's not that hard but I can't find anything anywhere.

Thanks!
0
Comment
Question by:NeoTeq
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:ampapa
ID: 9927532
Take a look at this link: http://www.experts-exchange.com/Databases/MS_Access/Q_20588638.html

Word (.DOC) I don't think is an option for Access though.
0
 
LVL 10

Author Comment

by:NeoTeq
ID: 9927575
RTF is fine, Word can easily be used to edit a file in RTF format. You'd expect Microsoft to offer more support for this kind of thing though. Well thanks for the help so far, I'm going to try to export a report instead of a query and I'm guessing how. If I succeed the points are yours, but any help with it is still appreciated.

-Neo
0
 
LVL 10

Author Comment

by:NeoTeq
ID: 9927638
Ok I guess I really do need help... I can only export a query but not a report? Is that MS logic or am I missing something, hoping for the last :)
0
 
LVL 8

Accepted Solution

by:
ampapa earned 175 total points
ID: 9927851
Give something similar to this a whirl:

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

From the help file:
The OutputTo method carries out the OutputTo action in Visual Basic.

expression.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding)

expression   Required. An expression that returns a DoCmd object.

ObjectType  Required AcOutputObjectType. The type of object to output.

AcOutputObjectType can be one of these AcOutputObjectType constants.
acOutputDataAccessPage  Not supported.
acOutputForm
acOutputFunction
acOutputModule
acOutputQuery
acOutputReport
acOutputServerView
acOutputStoredProcedure
acOutputTable

ObjectName  Optional Variant. 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  Optional Variant. The output format, expressed as an AcFormat constant. If you omit this argument, Microsoft Access prompts you for the output format.

AcFormat can be one of these AcFormat constants.
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS

OutputFile  Optional Variant. 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  Optional Variant. 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  Optional Variant. 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.

Encoding  Optional Variant.

0
 
LVL 10

Author Comment

by:NeoTeq
ID: 9927910
Already thought it would be something like that... foolish of me not to think of it. Nevertheless, thanks a lot for the quick response, you've saved me a lot of time. And since word is the standard editor for rtf, I don't even have to open an application.

Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now