Email with textbox value in message (1 Viewer)

Jonny45wakey

Member
Local time
Today, 06:32
Joined
May 4, 2020
Messages
40
Hello

I have a form in my Access database which has a cmd button with the following code, what i would like to do is include the values from txtEnquiryID and txtCustomer
on the form in the message body of the email.

How would i amend the code below, it works now to send the email but just need this small amendment please?

Private Sub Command133_Click()
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String

Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryEmailCreditCheck", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(2)) = False Then
sToName = .Fields(2)
sSubject = "GATE 1 - Client Credit Check Required"
stEnquiryID = Me.EnquiryID
stCustomer = Me.Customer
sMessageBody = "A new enquiry requires Client Credit Check to be carried out."


DoCmd.SendObject acSendNoObject, , , _
sToName, , , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With

Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:32
Joined
Sep 21, 2011
Messages
14,299
Just concatenate them with sMessageBody or build up a decent sentence inserting them where needed using the same method.
However you do it though, you do need to get the names correct, so decide which they should be, prefixed with txt or not.
 

Users who are viewing this thread

Top Bottom