Re: Email single record on a report

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

Thanks, working great now! Really appreciate it!

Take care

Colin
Rick Brandt wrote:
<weircolin@xxxxxxxxxxxxxx> wrote in message
news:1157376739.092389.206520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

.



Relevant Pages

  • Re: Email single record on a report
    ... I have a form and I am wanting to be able to email the current record ... SendObject doesn't have a WHERE argument like OpenReport does. ... 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 ...
    (microsoft.public.access.reports)
  • RE: Trouble generating Filter for emailing report...
    ... I ended up filtering on the query as you said, ... will not filter a report. ... Static myCallID As Variant ...
    (microsoft.public.access.formscoding)
  • RE: Update Query - Automatically Store Todays Date
    ... Dim strMsg As String ... The pop up message boxes work fine, the messgaes appeared as the report ... should not contain any filtering regarding the date. ... Allen Browne's Client Search form uses the form FilterOn property to ...
    (microsoft.public.access.queries)
  • Re: Managing the flow of forms...
    ... One main modal form, which serves as what the user sees when no forms are ... >> ElseIf TypeOf objMe Is Report Then ... >> interface the reports if that uses combos to offer filtering options), ... >> Public Function OpenTheReport(strDoc As String, ...
    (microsoft.public.access.forms)
  • RE: Update Query - Automatically Store Todays Date
    ... The record source for the report ... should not contain any filtering regarding the date. ... the same filtering criteria as your form. ... records with a date (As the search form is not just for printing reports). ...
    (microsoft.public.access.queries)