Printing a series of reports

H

Harry V

I'm using ACCESS 2003 and ADO

I'm trying to print a series of reports from a form. The form asks for key
field values, formats and executes SQL to bring a number of records into a
recordset and moves through the recordset via a Do While Not recordset EOF
loop
to build a filter clause to pass to a report, as well as a file name to
output text files to and run the commands:

DoCmd.OpenReport "myReport", acViewPreview, "myQuery", myFilter
DoCmd.OutputTo acOutputReport, "myReport", acFormatTXT, myFileName, False

Each report is run in turn, but I don't have the opportunity to close each
file during the preview, in fact a single preview is displayed while messages
flash saying it is writing each file. The files, though named properly, all
end up with the same text, rather than different report text content.

I'm missing something - is there a way to force a pause between each report
during preview or is there a property in the report that ensures that the
report is closed before then next one is opened? The preview isn't necessary
- the user only needs the text files.
 
D

David Lloyd

Harry:

If you just need the reports as text files, I would suggest something like
the following:

DoCmd.OpenReport "myReport", acViewPreview, "myQuery", myFilter, acHidden
DoCmd.OutputTo acOutputReport, "", acFormatTXT, myFileName, False
DoCmd.Close acReport, "myReport", acSaveNo

By not specifying the ObjectName parameter in the OutputTo method, the
active object (in this case the report) is chosen by default. The acHidden
parameter of the OpenReport method makes the Print Preview invisible to the
user. The Close method takes care of closing the report on each iteration
through the loop.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I'm using ACCESS 2003 and ADO

I'm trying to print a series of reports from a form. The form asks for key
field values, formats and executes SQL to bring a number of records into a
recordset and moves through the recordset via a Do While Not recordset EOF
loop
to build a filter clause to pass to a report, as well as a file name to
output text files to and run the commands:

DoCmd.OpenReport "myReport", acViewPreview, "myQuery", myFilter
DoCmd.OutputTo acOutputReport, "myReport", acFormatTXT, myFileName, False

Each report is run in turn, but I don't have the opportunity to close each
file during the preview, in fact a single preview is displayed while
messages
flash saying it is writing each file. The files, though named properly, all
end up with the same text, rather than different report text content.

I'm missing something - is there a way to force a pause between each report
during preview or is there a property in the report that ensures that the
report is closed before then next one is opened? The preview isn't
necessary
- the user only needs the text files.
 
H

Harry V

thanks David, but in trying that solution, I get an error:

Run-time error "2487"
The ObjectType argument for the action or method is blank or invalid.

But putting the report name back in worked just fine.

I was looking for the close statement, but it didn't appear to apply to a
report.

Thank you

Harry V
 
D

David Lloyd

Harry:

I didn't get an error using an empty string as the ObjectName for the
OutputTo method. This syntax is supported according to the Access help
topic for this method.

Nevertheless, I am glad you were able to make it work.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


thanks David, but in trying that solution, I get an error:

Run-time error "2487"
The ObjectType argument for the action or method is blank or invalid.

But putting the report name back in worked just fine.

I was looking for the close statement, but it didn't appear to apply to a
report.

Thank you

Harry V
 

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