Jonny45wakey
Member
- Local time
- Today, 08:38
- Joined
- May 4, 2020
- Messages
- 48
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
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