Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.SendObject - How do I mail Report with Criteria (SQL ADP)

Status
Not open for further replies.

Duanw

IS-IT--Management
Dec 5, 2005
7
GB
Hi All

I recently stumbled upon this forum. Hope you guys can help me out because I have been stumped up till now. Here goes:

I upsized my Access Database to SQL, which worked fine. I however have a jobsheet report which must be mailed to employees. When opening the report it used to get the field details from a form, opening it with the correct information inside. Now it is based on a query, but cannot get the details from the form. I am using the DoCmd.SendObject method, but you cannot narrow down criteria in the same manner as using DoCmd.OpenReport. Can the report get the parameters from the form fields in the same manner as in a normal Access MDB, or is there a way to open the report and filtering it before sending. (Can't find any way to implement OpenArgs!!)

Thanks in advance.

D
 
I do something similar and only the one record is emailed. But I open the report first. Maybe that makes a difference.

Code:
Dim strSubject As String
Dim strRecipient As String
Dim strCC As String
Dim stLinkCriteria As String


strSubject = Me.txtSubject
strRecipient = Me.txtRecipient
strCC = Me.txtCC
stLinkCriteria = "[Phone_Message_ID] = " & Me.txtPhoneMessageID

DoCmd.OpenReport "rptPhoneMessages", acViewPreview, , stLinkCriteria
    
       
DoCmd.SendObject acReport, "rptPhoneMessages", "RichTextFormat(*.rtf)", strRecipient, strCC, "", "phone message for " & strSubject, "your phone message " & strSubject & " is attached", True, ""

DoCmd.Close acReport, "rptPhoneMessages"  
Me.txtRecipient.SetFocus
 
Thank you very much. That worked like a charm.

D :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top