Consulting

Results 1 to 4 of 4

Thread: How to use a string variable for amending an email message

  1. #1

    How to use a string variable for amending an email message

    Good afternoon,

    I want to use a variable (text) to complete an email but I cannot manage to insert the variable value in the email text message.
    In the example here below I have 2 string variables : VehicleType and VehicleVin. I would like to use these information to update the text in my email message that should become "Vehicle profile"& VehicleType. But I cannot make it work

    Private Sub CmdVehicleProfileEMail_Click()
    On Error GoTo CmdVehicleProfileEmail_Click_Err
    Dim VehicleNumber As Integer
    Dim VehicleType As String
    Dim VehicleVin As String
    VehicleNumber = [TFleetRef]
    DoCmd.OpenForm "FQTVehicleProfileEMail", acNormal
    DoCmd.ApplyFilter "", "TFleetRef=" & VehicleNumber
    DoCmd.SendObject acForm, "FQTVehicleProfileEMail", "PDFFormat(*.pdf)", "", "", "", "Profile vehicle"
    DoCmd.Close
    CmdVehicleProfileEMail_Click_Exit:
    Exit Sub
    CmdVehicleProfileEmail_Click_Err:
    MsgBox "Your e-mail has not been sent"
    DoCmd.Close acForm, "FQTVehicleProfileEMail"
    DoCmd.Close acForm, "FQTVehicleProfile"
    Resume CmdVehicleProfileEMail_Click_Exit
    End Sub

    Can somebody help it ?

    Thanks and regards

  2. #2
    VBAX Regular
    Joined
    Jun 2009
    Location
    Dorset
    Posts
    60
    Location
    Try this

    DoCmd.SendObject acForm, "FQTVehicleProfileEMail", "PDFFormat(*.pdf)", "", "", "", "Profile vehicle", "Vehicle profile" & VehicleType
    Regards
    JD
    ------------------------------------
    Software-Matters
    Dorset

  3. #3
    Hello and thanks for the message. I have changed it. Now I just get the raw text "Vehicle profile" on the Outlook message. The value of the variables are not brought to the message. Thanks a lot in and any case.

    Regards, Xavier

  4. #4
    You are not setting any values in the variables VehicleType and VehicleVin. Where do the values come from?

    Try something like this:

    NOTE: You will need to update the code below for the two lines ending with the comment <<<< get value from somewhere

    Private Sub CmdVehicleProfileEMail_Click()
    On Error GoTo CmdVehicleProfileEmail_Click_Err
    Dim VehicleNumber As Integer
    Dim VehicleType As String
    Dim VehicleVin As String
    VehicleNumber = [TFleetRef]
    
    ' set the values here
    
    VehicleType = ""   ' <<<< get value from somewhere
    VehicleVin = ""  ' ' <<<< get value from somewhere
    
    DoCmd.OpenForm "FQTVehicleProfileEMail", acNormal
    DoCmd.ApplyFilter "", "TFleetRef=" & VehicleNumber
    DoCmd.SendObject acForm, "FQTVehicleProfileEMail", "PDFFormat(*.pdf)", "", "", "", "Profile vehicle", "Vehicle Type: " & VehicleType & " - VIN " & VehicleVin
    DoCmd.Close
    CmdVehicleProfileEMail_Click_Exit:
    Exit Sub
    CmdVehicleProfileEmail_Click_Err:
    MsgBox "Your e-mail has not been sent"
    DoCmd.Close acForm, "FQTVehicleProfileEMail"
    DoCmd.Close acForm, "FQTVehicleProfile"
    Resume CmdVehicleProfileEMail_Click_Exit
    End Sub
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

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