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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send single record through outlook 2

Status
Not open for further replies.

Neowynds

Technical User
Sep 25, 2003
52
US
I have a button set up on the bottom of my database with the following code to send the form frmSIR via email.

Private Sub Command64_Click()
On Error GoTo Err_Command64_Click

Dim stDocName As String

stDocName = "frmSIR"
DoCmd.SendObject acForm, stDocName

Exit_Command64_Click:
Exit Sub

Err_Command64_Click:
MsgBox Err.Description
Resume Exit_Command64_Click

End Sub

Unfortunately it sends all the records. Is there any way to set it up to only send the current record?

Thanks in Advance

Neo
 
Well, there is no way to filter the records using the SendObject method. You would need to filter them on the form first or send the record to a query and send that. You can try this.

Private Sub Command64_Click()
On Error GoTo Err_Command64_Click

Dim stDocName As String
Me.RecordsetClone.FindFirst "[FieldName] = " & Me![FormControl] & ""
Me.Bookmark = Me.RecordsetClone.Bookmark
stDocName = "frmSIR"
DoCmd.SendObject acForm, stDocName

Exit_Command64_Click:
Exit Sub

Err_Command64_Click:
MsgBox Err.Description
Resume Exit_Command64_Click

End Sub
You will need to change the arugment in BOLD to the name of a field in the underlying Record Source and a Control on your form that would point specifically to the current record, but that should filter it so when you send the object it just sends one record.

Paul

 
I thought I had a handle on this, but I don't. How would I do the same, but with this code below:

DoCmd.SendObject acSendReport, "rpt_QuoteEmail", acFormatSNP, "", , , , , True

Please help.

Thanks.

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
I tried this, but it is not working:

DoCmd.SendObject acSendReport, [InvoiceNumberID]=" & Forms![frm_Invoice]![InvoiceNumberID], "rpt_QuoteEmail", acFormatSNP, "", , , , , True


The code is in red, which is telling me something is wrong.

What did I do wrong with the code above?

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
I found the answer.

I used the following code:
DoCmd.SendObject acSendReport, "rpt_QuoteEmail", acFormatSNP, "", , , , , True

Then I put the following on the OnOpen Event of the report:

Me.Filter = "InvoiceNumberID=" & Forms![frm_Invoice]![InvoiceNumberID]
Me.FilterOn = True

I hope this helps someone else.

Thanks,

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Hi!

I have very little experience with the sendobject thingie, but I believe PaulBricker is correct when stating Well, there is no way to filter the records using the SendObject method.

The code in your last post is not correct, because SendObject does not allow for a filter criteria (look it up in help)

The trick used for the form, was to filter the form to show only the record (i e the recordset of the form contained only one record) prior to sending. And as you see, in that code, the form was sent, not a report.

To achieve the same with a report, I believe you would have to set a criteria in the query of the report. In other words, set the criteriea of the InvoiceID field in your query to be:

[tt]Forms![frm_Invoice]![InvoiceNumberID][/tt]

HTH Roy-Vidar
 
aaahh - yes sending the filter to the report also - of course - good one! Must have submitted at the same time, there...

Roy-Vidar
 
Yes we must have passed each other with our responses:)

You have a GREAT NEW YEAR!!!!

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
I entered the following and I get errors: Procedure Declaration does not match description of event...
tMain is the main table and iSMRecord is the record number.

Private Sub Mail4_Click()
On Error GoTo Err_Mail4_Click

Dim stDocName As String
Me.RecordsetClone.FindFirst "[tmain] = " & Me![iSMRecord] & ""
Me.Bookmark = Me.RecordsetClone.Bookmark
stDocName = "temptmain"
DoCmd.SendObject acForm, stDocName

Exit_Mail4_Click:
Exit Sub

Err_Mail4_Click:
MsgBox Err.Description
Resume Exit_Mail4_Click


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top