Results 1 to 2 of 2
  1. #1
    Rinoaerith is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    9

    Sending email body as concatenated text based on a cbobox and after update event

    Here is another question:

    I have a form called "frmDesignation" in which I have the following fields:

    analyst Name (is a cbobox)
    Document
    Block
    e-mail (analyst email)



    In this form each line record is composed for a description of a Block and a document to be assigned to an analyst by the area supervisor.

    The field analyst Name has a VBA code in the afterupdate event that when the supervisor choose the analyst from cbobox, It prompts the outlook warning to send a static standard message in an outlook email. It is working perfectly, no problems.

    But I would like to know how could I include the fields "Document" and "Block" as part of a concatenated text body in the email depending on the analyst that is being picked in this form.

    Code:
    Private Sub analyst Name_AfterUpdate()
    Dim sSubject As String
    Dim stMail As String
    Dim strBody As String
    'message subject
    sSubject = "A new task was assigned to you"
    'sends email to name in Employee on the current form
    stMail = DLookup("[e-mail]", "Employee", "[e-mail]= Form![frmDesignation].[e-mail]")
    'email body
    strBody = "The following document was assigned to your evaluation:" & Form![frmDesignation].[Block] & Form![frmDesignation].[Document]"
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.SendObject acSendNoObject, , , stMail, , , sSubject, strBody, False
    End Sub
    But I am having a sintax error and in fact, I think that I have to use in some way the dlookup function to lookup for the analyst Name in this form and then to return the assigned Block and document... I just dont know how to write it to work.

    I think that is also a very basic question for you, but for me as a newbie trying to understand, is very difficult. I even understood sometimes the logical involved but I am not capable to write it down (yet, because I am studying VBA in one site that was informed to me)...

    thank you again!
    Last edited by Rinoaerith; 05-06-2014 at 08:34 PM. Reason: wrong frm name in code

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I handle mine a little differently, but here is the gist of it. Maybe you adapt this to your needs. Good Luck!


    Dim strMsgBody As String
    strMsgBody = Me.EmailMessage 'This would be you Combobox Value.
    DoCmd.SendObject , , , strToWhom, , strBcc, strSubject, strMsgBody, True

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

Similar Threads

  1. Replies: 3
    Last Post: 03-25-2013, 11:01 PM
  2. Replies: 3
    Last Post: 04-15-2012, 05:25 PM
  3. Replies: 1
    Last Post: 02-21-2012, 09:09 AM
  4. sending data into an email body - outlook
    By webisti in forum Access
    Replies: 6
    Last Post: 02-15-2012, 07:05 AM
  5. update database using email body text
    By ravindramn in forum Import/Export Data
    Replies: 0
    Last Post: 05-19-2011, 06:34 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