Results 1 to 4 of 4
  1. #1
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234

    Email command button coding needed

    Hi All,

    Below are pictures of chldRelEventEmployee. Notice in the upper right-hand corner is the email command button. I need to build an "on click" event that will open up the email program to email everyone who is listed as staff for the event.



    Don't even know where to begin.

    Click image for larger version. 

Name:	Staffing rpt view.png 
Views:	7 
Size:	26.5 KB 
ID:	22360 Click image for larger version. 

Name:	Staffing dsgn view.png 
Views:	7 
Size:	14.9 KB 
ID:	22361

  2. #2
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Update: Here's the code that's already attached to cmdEmail:
    Private Sub cmdEmail_Click()
    If Not IsNull(Forms!frmEvent!txtEventID) Then
    If IsNull(Forms!frmEvent!cboSelClient) Then
    MsgBox "You must first select a Client in order to perform this action."
    Forms!frmEvent!cboSelClient.SetFocus
    Exit Sub
    Else
    End If

    If IsNull(Forms!frmEvent!txtEventDate) Then
    MsgBox "You must first specify an Event Date in order to perform this action."
    Forms!frmEvent!txtEventDate.SetFocus
    Exit Sub
    Else
    End If

    If IsNull(Forms!frmEvent!cboSelEventStatus) Then
    MsgBox "You must first specify the Event Status in order to perform this action."
    Forms!frmEvent!cboSelEventStatus.SetFocus
    Exit Sub
    Else
    End If
    Else
    End If
    Dim db As Database
    Dim rst As Recordset
    Dim rstEmp As Recordset
    Dim CorEmpID As String
    Dim CorEventNum As String
    Dim CorEmpEmailList As String
    Dim CorEventDate As String
    Dim CorEventDateShort As String
    Dim CorEventTime As String

    Set db = CurrentDb
    Set rst = Me.RecordsetClone
    Set rstEmp = db.OpenRecordset("tblEmployeeAction")

    CorEventNum = Nz(Forms!frmEvent!txtEventNumber)
    CorEventDate = Format(Nz(Forms!frmEvent!txtEventDate), "Long Date")
    CorEventDateShort = Format(Nz(Forms!frmEvent!txtEventDate), "Short Date")
    CorEventTime = Format(Nz(Forms!frmEvent!txtValetArrival), "h:nn AM/PM")

    rst.MoveFirst
    Do While Not rst.EOF
    If Not IsNull(rst.Fields("email")) Then
    If IsNull(CorEmpEmailList) Or CorEmpEmailList = "" Then
    CorEmpEmailList = rst.Fields("email")
    Else
    CorEmpEmailList = CorEmpEmailList & "; " & rst.Fields("email")
    End If
    CorEmpID = rst.Fields("EmployeeID")
    With rstEmp
    .AddNew
    .Fields("EmployeeID") = CorEmpID
    .Fields("ActionDate") = Format(Now(), "short date")
    .Fields("EffectiveDate") = Format(Now(), "short date")
    .Fields("ActionTypeID") = 5
    .Fields("Remarks") = "Email: #" & CorEventNum & ", " & CorEventDateShort
    .Update
    End With
    End If
    rst.MoveNext
    Loop
    rstEmp.Close
    DoCmd.SendObject acSendReport, "rptEventEmail", acFormatRTF, , , CorEmpEmailList, "Event: " & CorEventDate & ", " & CorEventTime, "If you have any questions or believe you have been staffed on this event by error, please immediately call the valet office at (415) 447-1700"


    'Error:
    'MsgBox ("Either you have not staffed any Employees, or the Employees you have staffed do not have e-maill addresses.")
    End Sub


    However, it opens up the email, but doesn't put their email addresses in the email form. Their email addresses are on CorEmpEmailList, as well as tblEmployee.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Here is an example of sending a single email. To send multiple emails you would need to loop through a recordset. I would recommend using DAO to open a recordset.
    https://www.accessforums.net/import-...tml#post281258

  4. #4
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Actually, I realized that it works. I didn't see that all the names of the employees were in the BCC line.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 07-14-2015, 02:41 PM
  2. Command Button to Send Outlook Email
    By AJM229 in forum Forms
    Replies: 19
    Last Post: 05-07-2014, 09:05 AM
  3. Email coding
    By arrowmakersuk in forum Access
    Replies: 3
    Last Post: 12-19-2011, 10:06 AM
  4. Command button to open email template
    By avarusbrightfyre in forum Import/Export Data
    Replies: 5
    Last Post: 09-10-2011, 11:18 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums