Email single record on a report

  • Thread starter Thread starter weircolin
  • Start date Start date
W

weircolin

Hi

I have a form and I am wanting to be able to email the current record
that is showing, but it's not wanting to play. This is the code I am
using.

Dim stDocName As String

stDocName = "rptnewsletterdatabase"
strWhere = "[Reference Number] = " & Me.[Reference Number]
DoCmd.SendObject acReport, stDocName, , strWhere


Can anyone help me?

Thanks

Colin
 
Hi

I have a form and I am wanting to be able to email the current record
that is showing, but it's not wanting to play. This is the code I am
using.

Dim stDocName As String

stDocName = "rptnewsletterdatabase"
strWhere = "[Reference Number] = " & Me.[Reference Number]
DoCmd.SendObject acReport, stDocName, , strWhere

SendObject doesn't have a WHERE argument like OpenReport does. You have a few
alternatives.

You can exploit a behavior in Access wherein executing a report that is already
opened in preview mode will always produce the same filtering as the one being
previewed. So if you use OpenReport to preview the report with your WHERE
clause and then immediately follow that line of code with your SendObject line
then the report in your Email will be filtered identically.

You can put your WHERE clause in a variable or form control and then have the
Open event of the report run code that evaluates it and applies that same filter
to itself.

You can modify the SQL of the Report's RecordSource query on-the-fly with your
code and then use SendObject.
 
Hi

Thanks, working great now! Really appreciate it!

Take care

Colin
Rick said:
Hi

I have a form and I am wanting to be able to email the current record
that is showing, but it's not wanting to play. This is the code I am
using.

Dim stDocName As String

stDocName = "rptnewsletterdatabase"
strWhere = "[Reference Number] = " & Me.[Reference Number]
DoCmd.SendObject acReport, stDocName, , strWhere

SendObject doesn't have a WHERE argument like OpenReport does. You have a few
alternatives.

You can exploit a behavior in Access wherein executing a report that is already
opened in preview mode will always produce the same filtering as the one being
previewed. So if you use OpenReport to preview the report with your WHERE
clause and then immediately follow that line of code with your SendObject line
then the report in your Email will be filtered identically.

You can put your WHERE clause in a variable or form control and then have the
Open event of the report run code that evaluates it and applies that same filter
to itself.

You can modify the SQL of the Report's RecordSource query on-the-fly with your
code and then use SendObject.
 
Back
Top