Emailing with field name in body of email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I have a small issue I hope. Below is the code I use for sending an email
from an Access form. It's works great and does excatly what I want it to do
except for one thing; I would like for the Field name to show in the email.
Currently, I am getting the information that is in the field but I also want
to capture the name of the field the information is coming from. Any help
would be appreciated!!

Thanks!!!

Code:

Private Sub cmdSendEmail_Click()
On Error GoTo EH
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = ""
MySubject = "Procedure Update"
MyMessage = Me.ProcNumber & vbCr & Me.ProcName & vbCr & Me.EffDate & _
vbCr & Me.Comments
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub
 
It's not clear to me what Field name it is you're trying to get. Currently,
your message contains the value contained in 4 different controls on your
form. Which field name is it you want?
 
Hi Doug,

Sorry about that. The field names are:

Procedure Number, Procedure Name, Effective Date and Comments.

Thanks!!
 
How about the following
MyMessage = "Procedure No: " & Me.ProcNumber & vbCr & "Procedure Name:
"& Me.ProcName & vbCr & "Effective Date: " & Me.EffDate & vbCr &
"Comments: " & Me.Comments

Haven't tested this by the way
 
So are you saying you want the name of the field for each of the 4 values?

What about something like:

MyMessage = "Procedure Number: " & Me.ProcNumber & vbCrLf & _
"Procedure Name: " & Me.ProcName & vbCrLf & _
"Effective Date: " & Me.EffDate & vbCrLf & _
"Comments: " & Me.Comments
 
That was absolutely perfect! Just what I was looking for. Thank you so much
for help Doug, I really appreciate it!!
 
Back
Top