E-mailing a report

  • Thread starter Thread starter Kate Cz
  • Start date Start date
K

Kate Cz

Hello, I've seen several postings, but am a beginner and don't understand
quite yet:

How can I e-mail a report from a form of only the current record? When I try
to e-mail it now, the report contains all of my records. If anyone can help
the more direction the better ie if this requires code, where, what, how, etc.
If I can do it in a macro, that would be preferable as I do understand those.


Thank you,
 
Kate:

In the Click event of a form button, you might want to try code similar to
the following:

DoCmd.OpenReport "MyReport", acViewPreview, , "ID=" &
CInt(txtIDField), acHidden
DoCmd.SendObject acSendReport, "", acFormatSNP, "(e-mail address removed)",
, , "Email Subject", "Email Message", False
DoCmd.Close acReport, "MyReport", acSaveNo

The idea here is to use the Where parameter of the OpenReport method ("ID="
& CInt(txtIDField) ) to limit the report to a single record. This example
assumes you have an ID field on your form in a textbox called txtIDField.
You will have to adjust this to use a field on your form that distinguishes
each record. Once we have opened the filtered report, we can call the
SendObject method to email the open report to the recipient. Finally, the
open report is closed.

I have used the acFormatSNP constant to email a snapshot in this example.
You can choose another format to suit your needs.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Hello, I've seen several postings, but am a beginner and don't understand
quite yet:

How can I e-mail a report from a form of only the current record? When I try
to e-mail it now, the report contains all of my records. If anyone can help
the more direction the better ie if this requires code, where, what, how,
etc.
If I can do it in a macro, that would be preferable as I do understand
those.


Thank you,
 
Much Appreciated David - This helped thank you.
David said:
Kate:

In the Click event of a form button, you might want to try code similar to
the following:

DoCmd.OpenReport "MyReport", acViewPreview, , "ID=" &
CInt(txtIDField), acHidden
DoCmd.SendObject acSendReport, "", acFormatSNP, "(e-mail address removed)",
, , "Email Subject", "Email Message", False
DoCmd.Close acReport, "MyReport", acSaveNo

The idea here is to use the Where parameter of the OpenReport method ("ID="
& CInt(txtIDField) ) to limit the report to a single record. This example
assumes you have an ID field on your form in a textbox called txtIDField.
You will have to adjust this to use a field on your form that distinguishes
each record. Once we have opened the filtered report, we can call the
SendObject method to email the open report to the recipient. Finally, the
open report is closed.

I have used the acFormatSNP constant to email a snapshot in this example.
You can choose another format to suit your needs.

Hello, I've seen several postings, but am a beginner and don't understand
quite yet:

How can I e-mail a report from a form of only the current record? When I try
to e-mail it now, the report contains all of my records. If anyone can help
the more direction the better ie if this requires code, where, what, how,
etc.
If I can do it in a macro, that would be preferable as I do understand
those.

Thank you,
 
Dear David:

Your method is quite helpful. But I have one more question, since my form
has another subform (ID, and e-mail address) to keep all e-mail addresses.

How can I mail the report to those who has the same ID??? Since the way you
provide is the dedicated e-mail address.

Thanks.

Vivi
 
Back
Top