Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Report and output to file VBA - assistance

Status
Not open for further replies.

newbee2

Technical User
Apr 21, 2002
85
Hi,
Sorry to bother.
Using the following code snippet,I was hoping to test an application to output a report for later e-mail.
The code runs but stops with no indication of error but there is one. Where am I going wrong?
'open the Database
With accessApp
.OpenCurrentDatabase ("D:\My Documents\WORKS CARD.mdb")
End With

'open the report and print
DoCmd.OpenReport "MarketUnionConvertReport", acViewPreview
Visible = False
'Output the Report to file
DoCmd.OutputTo acOutputReport, "MarketUnionConvertReport", acFormatRTF, "C:\My Documents\Test", "MarketUnionConvertReport.rtf"
'Close access session
accessApp.Quit
Set accessApp = Nothing
Thanks in advance
Bill
 
Hi Bill,

I see one potential issue that might be causing this problem.

The command: DoCmd.OutputTo acOutputReport, "MarketUnionConvertReport", acFormatRTF, "C:\My Documents\Test", "MarketUnionConvertReport.rtf"

should be?:

DoCmd.OutputTo acOutputReport, "MarketUnionConvertReport", acFormatRTF, "C:\My Documents\MarketUnionConvertReport.rtf"

Also, why are you opening the report in Preview mode and then hiding it? The report doesn't need to be open for the OutputTo Action to work.

dz
dzaccess@yahoo.com
 
Thanks,

I was on the wrong belief that you had to open the object B4 you outputed. Don't know enough about the method.
Thanks agian
Regards
Bill
 
No problema...I was just curious why you opened the Report. I don't think that is actually causing the problem unless the report must be closed when you output it. The problem is more likely a result of the extra parameter in the DoCmd.OutputTo statement. Hopefully that will solve your issue.

Best, dz
dzaccess@yahoo.com
 
DZ,
Success, mission accomplished.
Kind Regards
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top