By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,046 Members | 2,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,046 IT Pros & Developers. It's quick & easy.

SendObject problem

P: n/a
I have finally got "SendObject" to work but now have a filter problem.

I have a database set up that I generate orders and print them as a single
page report. I've set up a filter so that when I "onclick" the button it
simply prints the order I can see (ie if I've entered Order 0100 - it only
prints the one that is open in the form).

I want the command button to continue printing but to also send the single
page by e-mail. However, although the print is still only printing the one
report the e-mail is attaching all of them - I have about 250 orders and
they all get attached to an e-mail.

Another "would be nice" is to have the actual report format attached to the
e-mail instead of RTF (snapshot would be nice but I don't think it works
with SendObject)

Can any guru's look at the attached code and tell me what I am doing wrong.

Private Sub Command85_Click()
On Error GoTo Err_Command85_Click

Dim stDocName As String
Dim stFilter As String

stDocName = "RptSiteInstruction"
stFilter = "ID = Forms!FrmInstruction!ID"
DoCmd.OpenReport stDocName, acViewNormal, , stFilter
DoCmd.SendObject acSendReport, stDocName, acFormatRTF,
"ja**@email.address.au", , , "Subject Text", , True
Exit_Command85_Click:
Exit Sub

Err_Command85_Click:
MsgBox Err.Description
Resume Exit_Command85_Click

End Sub

--
John Taylor

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"John Taylor" <ja**@iinet.net.au> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
I have finally got "SendObject" to work but now have a filter problem.

I have a database set up that I generate orders and print them as a single
page report. I've set up a filter so that when I "onclick" the button it
simply prints the order I can see (ie if I've entered Order 0100 - it only
prints the one that is open in the form).

I want the command button to continue printing but to also send the single
page by e-mail. However, although the print is still only printing the one
report the e-mail is attaching all of them - I have about 250 orders and
they all get attached to an e-mail.

Another "would be nice" is to have the actual report format attached to the
e-mail instead of RTF (snapshot would be nice but I don't think it works with
SendObject)

Can any guru's look at the attached code and tell me what I am doing wrong.


The problem is that SendObject doesn't have an optional WHERE argument like
OpenReport does (your strFilter variable). There are several ways to get the
same effect.

If you open the report in print preview and leave it on the screen when you
issue the SendObject command it will inherit the filtered data being displayed
in the report on-screen.

You can have the Open event of the Report test a value, either a public variable
or a control on your form and use that to apply a filter to itself. This is the
method I generally use.

If you always want to print/send the report from this form and will always be
doing so for one record at a time you can modify the query that the Report uses
so that it picks up selection criteria from the form.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.