Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    Tunbridge Wells, Kent. UK
    Posts
    24

    Cool Unanswered: assign a value to a variable

    Hi all,

    I could really use some help here!

    I have a query that returns, amongst other things, an email address.

    I want to capture this emailaddress value and assign it to a variable.

    Then I want to run DoCmd.Output report and place the variable in the "To:" field.

    I can't work out how to run a query (preferably in the background) and assign the emailaddress value to my variable?

    Can you help please??!!!

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Code:
    Dim EmailAddress As String
    EmailAddress = Nz(DLookUp("[tableCustomerEMailAddress]", "CustomerTableName", "[CustomerNameInTable] = '" & Me.CustomerNameOnForm & "'"), "")
    If EmailAddress = "" Then
       Msgbox "The Customer, " & Me.CustomerNameOnForm & ", has no E-Mail Address.", vbExclamation, "No E-Mail Address"

Posting Permissions

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