Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    34

    Unanswered: Input Query result into strEmail

    Hey everyone!

    This is hopefully very simple. I'm just trying to write in a simple email notification macro that bases the email address on a query result that only pulls up one email. The reason for doing this was so that the email could be changed whenever needed. The code example I'm using is:
    PHP Code:
    Dim strEmail As String
        
    strSubject As String
        
    strMessage As String
    strEmail 
    Me.assig_email
    strSubject 
    "New Work Order"
    strMessage =  "This is an automated email to let you know you have a new work order.  Have a nice day."
    DoCmd.SendObject acSendNoObject, , , strEmail, , , strSubjectstrMessageFalse 
    I want the query result to replace the Me.assig_email. Is this a simple matter or is there a better way? The function of this is to inform the database admin that a table was updated. Thank you for any help.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You could use DLookup:

    strEmail = DLookup("FieldName", "TableOrQueryName")
    Paul

  3. #3
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    119
    Yes this is a simple matter. As Paul says you could use DLookup or a query would work just as well.

    If the email address is on the form where the code is being triggered you will just need the field name i.e. strEmail = Me!EmailField

    Regards
    JD
    Regards
    JD

    Software-Matters

  4. #4
    Join Date
    Jul 2004
    Posts
    34
    Thanks! I figured it was easy, but I couldn't find something that would work. I seem to forget about that DLookup. Thanks again.

Posting Permissions

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