Outputting Flexible Data

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Outputting Flexible Data


Dave Gannon and Nich Mann


Producing static reports is easy—but what if your users want

to be able to customize their output? Dave Gannon and Nich

Mann look at all the options available to you and let you in on

the best answer.


We were recently posed a problem by a client: The

user wanted to produce, from Access, a set of

letters to go to customers (see Figure 1 for a

copy of the sample letter). Each letter included a number

of line-item records (a different number for every

customer) in the body of the document. The problem was

that the user needed to be able to customize the format of

the letter at any time—and without calling us.

We decided that the best solution was to use Word in

some way, allowing the user to modify the format of the

document in Word. Most developers think of paper-based

output coming directly from Access, but using Word to

produce output documents for Access data is often a great

way to go, especially if the end users value flexibility in

their output. From Access, we’d create new copies of the

letter and insert our data.

Having selected Word as our document generator,

we realized that there were various ways that we could

use Word. In this article we’ll show how we solved the

problem and what solution we picked. Before that,

though, we need to provide some background on ways

of outputting data from Access in printed format. There

are three ways of getting data into a Word document:

• OutputTo method

• Mail-merge

• Automation

Each has its advantages and disadvantages.


OutputTo method

Using OutputTo is probably the simplest way of exporting

your reports to Word. The effect is the same as when you

click the “Publish It with Microsoft Word” button (see

Figure 2).


It only takes one line of code to output a report in this

way, so the primary benefit is that this is a simple way of

exporting data:


DoCmd.OutputTo acOutputReport, "rptClientOrders", _

acFormatRTF, "MyReport.RTF", True, "Report.DOT"


This line of code will prompt the user for where to

save a copy of an Access report. The report will be

exported as a rich text format document. The output

document will be called MyReport.RTF. The True

following the document name will cause Word to be

started immediately after the document is created and

display the document to the user. The last parameter in

the call specifies a Word template document that will


Read more in the pdf Outputting Flexible Data