Allie,
this is ONE way -- not necessarily the best ...
(btw, freakazeud, thanks for the links -- you have posted them before -- When I was working on email functions my research brought me to you)
this code goes into a general module
CODE
'------------------------------------ EMailReport
Sub EMailReport(pReportName As String, pEmailAddress As String, pFriendlyName As String _
, pBooEditMessage As Boolean, pWhoFrom As String)
'Email a report to someone and construct the subject and message
'example useage: on the command button code to process a report
' EMailReport "MyReportname", "anyone@mymailbox.com", _
"The 3rd Quarter Profits Report", false, "Sally Smith"
'PARAMETERS
'pReportName --> "MyReportname"
'pEmailAddress --> "anyone@mymailbox.com"
'pFriendlyName --> "The 3rd Quarter Profits Report"
'pBooEditMessage --> true if you want to edit the message before mail is sent
' --> false if you want it to get sent automatically
'pWhoFrom --> "Sally Smith"
On Error GoTo EMailReport_error
DoCmd.SendObject acSendReport, pReportName, acFormatRTF, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage
Exit Sub
EMailReport_error:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix -- comment out next 2 lines when code is done
Stop
Resume
End Sub
this assumes the report has already been filtered and the filter has been saved
CODE
'------------------------------------ SetReportFilter
Sub SetReportFilter(pReportName As String, pFilter As String)
'Save a filter to the specified report
'You can do this before you send a report in an email message
'You can use this to filter subreports instead of putting criteria in the recordset
' USEAGE:
' example: in code that processes reports for viewing, printing, or email
' SetReportFilter "MyReportname","someID=1000"
' SetReportFilter "MyAppointments","City='Denver' AND dt_appt=#9/18/05#"
' written by Crystal
' Strive4peace2004@yahoo.ca
' PARAMETERS:
' pReportName is the name of your report
' pFilter is a valid filter string
On Error GoTo SetReportFilter_error
'---------- declare variables
Dim rpt As Report
'---------- open design view of report and set the report object variable
DoCmd.OpenReport pReportName, acViewDesign
Set rpt = Reports(pReportName)
'---------- set report filter and turn it on
rpt.Filter = pFilter
rpt.FilterOn = IIf(Len(pFilter) > 0, True, False)
'---------- save and close the changed report
DoCmd.Save acReport, pReportName
DoCmd.Close acReport, pReportName
'---------- Release object variable
Set rpt = Nothing
Exit Sub
SetReportFilter_error:
Resume Next
MsgBox Err.Description, , "ERROR " & Err.Number & " SetReportFilter"
'press F8 to step thru code and fix problem
Stop
Resume
'next line will be the one with the error
End Sub
both of these procedures are posted here:
code - basic procedures
http://www.utteraccess.com/forums/showflat...;Number=1036232In my opinion, the best format to send a report is SNAP if the users only need to look at it -- because it is an image, it looks exactly the same.
The above procedure sends it in RTF format -- lines and such don't translate well.
for SNAP format (user has to have the free reader), use
acFormatSNP
instead of
acFormatRTF
If you cannot render files in SNP (snapshot) format,
here is a link to the Microsoft site to download the SNAPSHOT viewer for Access
http://www.microsoft.com/downloads/details...;displaylang=en