Emailing Report

ekta

Registered User.
Local time
Today, 17:53
Joined
Sep 6, 2002
Messages
160
Emailing Report?

Hi All:

I want to email my report as an attachment using Outlook. I have downloaded Snapshot viewer but I don't know where to put the code for making it work. I tried adding a button on custom toolbar but it does not give me the option of adding the sendobject code. I also tried to add a command button on the report but it does not show me any events.
Where should I put the code???

Thanks,

Ekta
 
Don't know if this helps but I use this code to email a report directly from a form. Create a command button and add this code to the OnClick event.

Private Sub cmdYour Command Button Name_Click()
On Error GoTo Err_cmdYour Command Button Name

DoCmd.RunCommand acCmdSaveRecord

DoCmd.SendObject acSendReport, "Your Report name here", acFormatRTF, , , , "Your email subject line here", , True

Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_cmdYour Command Button Name _Click:
Exit Sub

Err_cmdYour Command Button Name _Click:

Resume Exit_cmdYour Command Button Name _Click

End Sub
 
Thanx for replying Barry. I don't want to email the report from the form. I want to email it from the report itself. If I add a command button on the report it does not show the events associated with it. Is there any way I can do that?
 
Reports are for displaying information while forms are used for user interaction - that's why command buttons are used for forms and not reports. Is there any reason why you don't want to email the report from the form? It shouldn't really make a great deal of difference. It will still look the same when it is emailed.
 
Hi Hayley,

I have a form where users enter some criteria and access filters the records that match the criteria and generate the report. Once the report opens, users want to email it using Outlook. How can I email the report using a form?

Ekta
 
Ekta

Just reliased that this sample does not add the attachment so you'll need to change the coding slightly

Private Sub CmdEmail_Click()
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("QryDynamic_QBF")

Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
DoCmd.SendObject , , , strEmail, , , _
"SUBJECT", _
"Good Morning" & _
vbCrLf & vbCrLf & "MESSAGE." & _
vbCrLf & vbCrLf & "MESSAGE LINE 2" & _
vbCrLf & vbCrLf & "Thanks" & _
vbCrLf & vbCrLf & "Best Regards" & _
vbCrLf & "SIGNATURE", false

rsEmail.MoveNext

Loop
Set rsEmail = Nothing

MsgBox "Emails have been sent"
End Sub

Where it says Docmd.sendobject - Add your report name in here - the commas show to,cc,bcc, subject so you can complete these as required. This loops through the recordset picking up each person in your table's email address and emails them in turn

Let me know if you need any further help.
Hay
 
Last edited:

Users who are viewing this thread

Back
Top Bottom