Results 1 to 5 of 5
  1. #1
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164

    Send Email via SendObject command with text from existing tables


    So I've managed to figure out how to send email using a simple DoCmd.SendObject command line that is part of an event procedure I've built into my form. However, I am wondering if I can somehow paste in data from a particular field or multiple fields in the form (or the table to which the form is locked). I have attempted things similar to the following: "Blah blah blah official email language" Combo90.Value "blah blah blah" but alas I get a syntax error. Since the purpose of the email is to call attention to a specific record in the database, it would be helpful if I could figure out how to reference that record in the email text. If anyone has any thoughts on the subject and felt like sharing I would be most grateful.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Must concatenate variables. Reference to controls is a variable. The & is the preferred concatenation operator in Access and VBA.

    "Blah blah blah official email language " & Me.Combo90 & " blah blah blah"
    Last edited by June7; 06-08-2012 at 11:42 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Okay now I feel really dumb, haha. I already concatenated some of my variables so as to display Last_Name, First_Name. I should have figured that out for myself but thanks! I'm sure this will work but I will wait until I've conducted thorough testing before I mark this thread as Solved.

  4. #4
    nhior is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    3
    try this

    On Error GoTo Err_cmdPreview_Click

    Dim stDocName As String

    stDocName = "Report"
    DoCmd.OpenReport stDocName, acPreview, , "TransactionID=" & [TransactionID]
    DoCmd.SendObject acSendReport, stDocName, acFormatRTF, Me.Combo126.Column(1), , , "Transaction Invoice", , True

  5. #5
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Thanks! Both suggestions are working nicely for me.

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

Similar Threads

  1. Replies: 10
    Last Post: 03-26-2012, 08:17 PM
  2. VBA Send Email using DoCmd.SendObject
    By malamute20 in forum Programming
    Replies: 15
    Last Post: 10-05-2011, 12:44 PM
  3. Aligning email message text when using SendObject
    By msoares in forum Programming
    Replies: 1
    Last Post: 02-15-2011, 07:22 AM
  4. Replies: 3
    Last Post: 12-28-2010, 04:40 PM
  5. Send email using SendObject instruction
    By stecco in forum Access
    Replies: 4
    Last Post: 09-09-2009, 01:55 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