Command Button to send current record via email?

B

buttercup560

Is it possible to customize a command button a form to have the record that
was just created sent via email? I've tried & tried and am having a hard
time!
 
S

SusanV

Use Docmd.sendobject using acNoObject, and define the message text using
your form controls. For example, if I have a table with 3 fields, and in my
form the controls are called FirstName, LastName and Street, and I wanted to
send an email alerting that a new person was added to the database, I would
use a button's onclick event like so:


Dim strFirst as String
Dim strLast as String
Dim strStreet as String
Dim msgtext As String

strFirst = Me.FirstName
strLast = Me.LastName
strStreet = Me.Street
msgtext = "New Person added: " & strFirst & strLast & ", " & strStreet

DoCmd.SendObject acSendNoObject, , , "you@your-email", , , "Subject",
msgtext

If the new person added was Joe Shmoe and the Street was 10 Main Street,
your email body would be:
New Person added: Joe Shmoe, 10 Main Street
 
Top