Save Report to file to be emailed

  • Thread starter Thread starter basic
  • Start date Start date
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
 
DoCmd.OutputTo acReport, "My Report", "RichTextFormat(*.rtf)",
"c:\MyReport.rtf", False, "", 0

This matches the OutputTo macro command for a report.
 
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.
 
Phil Smith said:
DoCmd.OutputTo acReport, "My Report", "RichTextFormat(*.rtf)",
"c:\MyReport.rtf", False, "", 0

This matches the OutputTo macro command for a report.
 
"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.
 
Back
Top