How do I print individual records as TEXT files in Access?

G

Guest

I had no trouble using ForceNewPage to export an Access report as a group of
HTML files, each containing one record per page. However, when I tried to
export to a file type other than html (specifically, *.txt), Access only
created the first file. Is there another way to create text files from
individual records?

I am using Microsoft Office Access 2003.
 
J

John Nurick

You'll need to export a separate report for each record. One way to do
it is

1) Create a parameter query that returns just one record, getting its
parameter (the primary key value of the record) from a text box on a
form (the parameter will be something like
Forms!MyForm!MyTextBox

2) Modify your report so it gets its data from the query.

3) Put a commandbutton on the form. In the button's Click event
procedure, write code that

-opens a recordset containing the primary key values of the records to
be exported
-loops through the recordset. For each record,
-sets the value of the textbox equal to the primary key value
-builds a suitable filename
-calls DoCmd.OutputTo to export the report, passing the filename
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top