Save Report to file to be emailed

B

basic

I have a program which at the push of button prints out invoices. I am trying
to get a copy of these invoice saved to a file of some sort so I can e-mail
it out to a customer. I know a little bit about Access but can't figure this
out. I think the code below is what triggers the printing, hopefully this
code is what needs tweaking to be able to get the invoices saved as a file.

' This function will print all of the priced invoices
'
Public Function PrintInvoicesWithPrices(Optional bPreview As Boolean)
Dim lType As Long, strF As String
On Error GoTo erh
If bPreview Then
lType = acViewPreview
Else
lType = acViewNormal
End If
SetReportType shpInvoiceWithPrices
strF = GetInvoiceFilterString
If strF = "" Then
Err.Raise vbObjectError + 1, "Shipping.Main", "The filter string used to
determine which invoices to print is blank (an error occured while comouting
it)."
End If
DoCmd.OpenReport "rptShipments", lType, , strF
GoTo eotf
erh:
apiuerror "Main", "PrintInvoicesWithPrices", 0
Resume eotf:
eotf:
End Function
 
P

Phil Smith

DoCmd.OutputTo acReport, "My Report", "RichTextFormat(*.rtf)",
"c:\MyReport.rtf", False, "", 0

This matches the OutputTo macro command for a report.
 
B

basic

Where do I put this code?


Phil Smith said:
DoCmd.OutputTo acReport, "My Report", "RichTextFormat(*.rtf)",
"c:\MyReport.rtf", False, "", 0

This matches the OutputTo macro command for a report.
 
B

basic

Phil Smith said:
DoCmd.OutputTo acReport, "My Report", "RichTextFormat(*.rtf)",
"c:\MyReport.rtf", False, "", 0

This matches the OutputTo macro command for a report.
 
P

Phil Smith

"DoCmd.OpenReport "rptShipments", lType, , strF"

Appears to be the bit of code which prints out the report.
If you want to print to paper AND print to file, put it directly after
this statement. If you want to print to file instead of paper, replace
it.
 

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