I need to E Mail a Report, Need To Add To Existing Code. See Below. Thanks, Dave

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

This code links the form with the report I want to e-mail instead of
printing.
The Customers E-Mail Link is already on the form, the control is named E
Mail
Outlook Express is active E-Mail client. Thanks, in Advance

On Error GoTo Err_Command450_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[Order ID]= Forms![Edit Quote]![Order ID]"

stDocName = "InvoiceReports"

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
'DoCmd.PrintOut acPage
'DoCmd.Close acReport = "InvoiceReports"

Exit_Command450_Click:


Exit Sub

Err_Command450_Click:
MsgBox Err.Description
Resume Exit_Command450_Click
 
Dave:

Basically what you want to do is to filter your report when its emailed;
SendObject doesn't by itself (and the menu items don't either) support
filters on objects being sent. There's two ways to resolve this:

1.) Change your report's underlying query to reference your form's Order ID
text box as the condition for the Order ID field.
2.) Change the query so that it "pulls" the values you want to use a filter
from a module variable in code. You can see how to do this by stopping by
our web and looking in the Code and Design Tips area under Reports for the
tip on how to supply report parameters via code.
 
Back
Top