Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Exporting an Acces Report using VBA

Posted on 2003-12-12
5
1,418 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

809 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