SendObject Help

  • Thread starter Thread starter jnariss
  • Start date Start date
J

jnariss

Guest
Hello,

I am having a problem figuring out SendObject. I created my database using Access 2003 and made a form and report. Both called Request. A user is to go onto the form and fill it out and then using the email button I would like to send the generated report I created. However the problem here is that everytime someone sends the email it sends every single report that has been created. Can I have it so that only the current report or form is emailed?

Please help me out here I have been trying to do this for days and I feel like I have searched all the previous posts in the forum.

Thank You,

Justine
 
Perhaps you could include your sendObject code.

"However the problem here is that everytime someone sends the email it sends every single report that has been created."
Surely you mean that it is sending the report for all records? Not every report.

If the report is only used for this form, you could filter the report using a key from the open form in the report based on a query. e.g. Forms("Customer").[Acct#].Value
If you try running the report without the form loaded, you will receive an error.
 
Hello,

I did mean all the records. The current SendObject code I am using is:

Private Sub btnEmail_Click()
DoCmd.SendObject acSendReport, "Request", acFormatHTML, "justine.nariss@egseg.com", , , "System Change Request", "A request for a System Change has been made. Please see the attached for more information.", , False
End Sub

-Justine
 
Try this - the bit "Me.YourRecordID" identifies the record you want to send in the report. Just change the bits to suit your terminology.

Dim stDocName As String
DoCmd.RunCommand acCmdSaveRecord
stDocName = "YourReportNameHere"

DoCmd.SendObject acSendReport, stDocName, acFormatHTML, , , "justine.nariss@egseg.com", , "Your message here " & Me.YourRecordIDHere
 
Justine,
I have used the following code to send single reports via email:
First is looks up the email address of the company, then sends that report only.
Hope this helps!!

Enviva

Private Sub cmdEmail_Click()
On Error GoTo cmdEmail_Click_Err
strEmail = DLookup("EmailAddress", "reportQuery", "[tblSample.ID] = " & Me![SampleID])
If IsNull(strEmail) Then
MsgBox "Company has NO Email Address"
Exit Sub
End If
stLinkCriteria = "[tblSample.ID] = " & Me![SampleID]

DoCmd.SendObject acReport, "ReportName", "Rich Text Format(*.rtf)", [strEmail], "", "", "SubjectMessage", "Message in body of text", , ""


cmdEmail_Click_Exit:
Exit Sub

cmdEmail_Click_Err:
MsgBox Error$
Resume cmdEmail_Click_Exit

End Sub
 
Enviva

How would you modify your code to deal with multiple recipients for the email?
 

Users who are viewing this thread

Back
Top Bottom