Results 1 to 13 of 13
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Emailing Page (2003)

    I have a command that emails an entire report, but I need another command that limits that report to the current record.

    I have no trouble printing the selected record with the following code:

    DoCmd.OpenReport stDocName, acNormal, _
    WhereCondition:="[tblShutins.ID]=" & Me.[tblShutins.ID]

    However, trying to email the same thing doesn't work as the compiler seems to think that the command ends after (*.snp)" and thus the Where condition is ignored. Here's the code:

    DoCmd.SendObject acReport, stDocName, "SnapshotFormat(*.snp)" _
    WhereCondition:="[tblShutins.ID]=" & Me.[tblShutins.ID]

    Any suggestions as to how to limit the emailed report to just the current record?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Emailing Page (2003)

    WhereCondition is not a valid argument for DoCmd.SendObject. You could change the record source of the report (or of a copy of the report) to a query that has

    [Forms]![NameOfTheForm]![tblShutins.ID]

    in the criteria for tblShutins.ID. Replace NameOfTheForm with the name of your form. You can then use

    DoCmd.SendObject acReport, stDocName, acFormatSNP

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Page (2003)

    I have everything set up as you suggested, but when running the query I get the following error message:

    Invalid bracketing of name '[Forms]![frmShutinWithVisits]![tblShutins.ID]'

    Darned if I can figure out what is invalid about it.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Emailing Page (2003)

    It's probably the period in ShutIns.ID. Try giving this control a different name without a period in it, and use that name in the expression.

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Emailing Page (2003)

    <hr>Invalid bracketing of name '[Forms]![frmShutinWithVisits]![tblShutins.ID]'<hr>
    Should this be

    [Forms]![frmShutinWithVisits]![tblShutins].[ID]

    i.e. separate brackets around the table name and the field name
    Regards
    John



  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Emailing Page (2003)

    Should you have both commands, the OpenReport in PREVIEW mode then the SendObject without the where clause.

    I seem to have done this in the past I think.

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Emailing Page (2003)

    I do this the same way that Patt mentioned.

    Open the report in Preview mode with a Where clause, then (while it is open)
    Use SendObject to Send the report.

    What is sent is the the report in Preview mode , so the Where clause gets used.
    Regards
    John



  8. #8
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Page (2003)

    That one didn't work.

  9. #9
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Page (2003)

    Using the Preview mode worked. That is, it printed out one page and then sent it to the email program. However, that hung the entire computer up with the Access status bar saying "Calculating".

  10. #10
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Emailing Page (2003)

    I don't know what to suggest. For me the Calculating message appears, but only momentarily then goes away.

    Did you close the report after sending it?

    DoCmd.OpenReport stDocName, acPreview, , strlinkcriteria
    DoCmd.SendObject acReport, stDocName, acFormatSNP, strVendorEmail, , , strSubject, strMessage, True
    DoCmd.Close acReport, stDocName
    Regards
    John



  11. #11
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Emailing Page (2003)

    You may want to change True to False at the end of the SendObject command. This allows the email to be sent straight away (False) or allows editting to the email before it is sent (True).

    I think Chuck got confused with mine and your solutions as they are both the same.

  12. #12
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Emailing Page (2003)

    I agree with you Patt that our solutions are the same.

    I deliberately want the True on the end to allow editing of the message, but I agree that it is a question you need to think about.
    Regards
    John



  13. #13
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Emailing Page (2003)

    Thanks again, Hans. That worked perfectly, and I needed True on the end so my wife can edit the message before sending it.

    You're a lifesaver!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •