I have and email button on one of my forms but I want to use that code
on a few more forms but don't want to copy the code on each form
because any changes I make to the code will need to be updated on each.
I was thinking I could use a Public Module so I can call it from
anywhere but I get the following error: External Name not defined.
It looks like it is not finding the Participant First Name from my
form. Here is my code. How can I fix this? I basically just want to
call the procedure from any form.
Public Sub SendMail()
On Error GoTo Err_cmdEmail:
'Provides the Send Mail automation
Dim dbs As DAO.Database
Dim strSubject As String
Dim strEmailAddress As String
Dim strCCEmail As String
Dim strEMailMsg As String
strSubject = "Employment verification for:" & " " & [Participant First
Name] & " " & [Participant Last Name] & " " & ", Please respond- 6
Month Check"
strEmailAddress = "em********@123.com"
strBCCEmail = [SupervisorEmail] & "; " & [HRContactFax] &
"@faxmail.com; " & [HRContactEmail]
Set dbs = CurrentDb
strEMailMsg = "Written Request for Employment Verification." _
& Chr(10) & "Today's Date:" & " " & Date & Chr(10) & Chr(10) _
& "Re:" & " " & [Participant First Name] & " " & [Participant Last
Name] & Chr(10) & Chr(10) & "Hello," _
& Chr(10) & Chr(10) & "The below information is currently on record
for:" & " " & [Participant First Name] & " " & [Participant Last Name]
_
& Chr(10) & Chr(10) & "Employer: " & " " & [OrganizationName] _
& Chr(10) & "Job Title: " & " " & [Job Description] _
& Chr(10) & "Pay Rate: " & " $" & [Starting Pay] & Chr(10) &
"Status (Full or Part time): " & " " & [Hours] _
& Chr(10) & "Start Date: " & " " & [BeginDate] _
& Chr(10) & Chr(10) & "To verify this information please do one of
the following:" _
& Chr(10) & Chr(10) & "1. Have Human Resources, or the immediate
supervisor make any changes or" _
& "corrections and return this letter via email or fax to Company
Name along with the Supervisor's " _
& "name and full contact information. Email: em********@123.com
Fax:" _
& Chr(10) & Chr(10) & "2. Fax a copy of the most recent paycheck
stub to (123) 456-7891. " _
& "Please make sure that the above information, Employee Name,
Company Name, Job Title, Pay Rate, " _
& "and Hours per week are included on or with the paycheck stub." _
& Chr(10) & Chr(10) & "I would greatly appreciate your response as
soon as possible but no later " _
& "than (Date). Keeping our information current enables us to keep
the terms of our grant contracts " _
& "and ensures that we will continue to receive the grants and
resources that make Company Name possible. Thanks for your help! " _
'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObject , , html, strEmailAddress, _
, strBCCEmail, strSubject, strEMailMsg, True, False
Err_cmdEmail:
If Err.Number = 2295 Then
MsgBox "There are no email addresses for the Supervisor or HR
Contact. The email message was not generated. Enter in valid email
addresses and try again.", _
vbInformation, "Email Message Can Not be Sent."
End If
End Sub
Thanks