Results 1 to 6 of 6
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    sendobject command

    I hope someone can tell me the best way to to this:

    I have a button that on click I send an email message to staff letting them know letters were mailed. I would like to add code to auto populate the number of letters based off a query I have created that contains the count.

    QueryName= "ltrcount"
    FieldName="sndltrcount" (this field calculates the number of records using GroupBy/Count)

    Can I auto populate the calculation from this field from query in the message being sent below?



    Here is my code:
    DoCmd.SendObject acSendNoObject, , , "FName.LName@tn.gov", "FName.LName@tn.gov", , "Non-Registered Prescriber Notification", "FName, " & [sndltrcount] & "letters have been mailed to a list of Non-Registered Prescribers," & vbNewLine & "if any of the letters come back undeliverable; please deliver to ______." & vbNewLine & vbNewLine & "Do Not log these in the Return Mail Database" & vbNewLine & vbNewLine & "Attached is a copy of the Template Letter." & vbNewLine & vbNewLine & "Thanks," & vbNewLine & "____", 1

    Thanks,
    Lisa

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can use a DLookup() to get the value of that field from the query and put it in the email. By the way, at some point it's easier to use a variable for the body of the email (or any argument that starts to get long).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    thanks I get a number when the email opens but it is the wrong number.

    attached is a print screen of my open query showing a count of 185.

    My email only shows 8.

    Can you tell me why it is only picking up the 8?
    Thanks,
    Click image for larger version. 

Name:	DLookUp.JPG 
Views:	7 
Size:	89.4 KB 
ID:	15844

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Put the field in quotes too.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Here is my final code that works. Thanks pbaldy for your expertise....

    DoCmd.SendObject acSendNoObject, , , "FName.LName@tn.gov", "FName.LName@tn.gov; FName.LName@tn.gov", , "Non-Registered Prescriber Notification", "FName, On " & DLookup("Send_LtrDate", "NumLtrsMailed") & ", " & DLookup("Count", "NumLtrsMailed") & " letters were mailed to a list of Non-Registered Prescribers," & vbNewLine & "if any of the letters come back undeliverable; please deliver to FName." & vbNewLine & vbNewLine & "Do Not log these in the Return Mail Database" & vbNewLine & vbNewLine & "Attached is a copy of the Template Letter." & vbNewLine & vbNewLine & "Thanks," & vbNewLine & "FName", 1

    Thanks,
    DCV0204

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SendObject Parameters
    By mlozano in forum Import/Export Data
    Replies: 1
    Last Post: 09-12-2012, 11:57 AM
  2. Replies: 4
    Last Post: 06-11-2012, 11:51 AM
  3. Replies: 3
    Last Post: 12-28-2010, 04:40 PM
  4. SendObject
    By weshader in forum Access
    Replies: 1
    Last Post: 11-09-2009, 04:19 PM
  5. SendObject Message
    By williammarino in forum Forms
    Replies: 4
    Last Post: 10-06-2009, 01:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums