Results 1 to 2 of 2
  1. #1
    bond is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    1

    how do i email only the selected record, access tries to email ALL records

    How do I "select current record" in order to email it. As is now, access tries to email all records.?

  2. #2
    essaytee's Avatar
    essaytee is offline Been around a while
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2008
    Location
    Melbourne, Australia
    Posts
    27
    Here are two sub procedures that I use in a working system. I'm sure you can adapt them.

    Code:
    Sub NotifyOvernight()
    On Error GoTo Error_In_Code
    
        Const k_EMAIL As String = "@whatever.vic.gov.au"
    
        Dim strEmailAdd As String, strSubject As String, strMessage As String
        Dim strMsg As String
        
        strMsg = strMsg & "An email will now be generated and sent to the Recommending Sub-Officer" & vbLf
        strMsg = strMsg & "informing that member of the Overnight Booking." & vbLf & vbLf
        strMsg = strMsg & "Microsoft Outlook will display a message advising that an email is attempting" & vbLf
        strMsg = strMsg & "to be sent.   Click 'YES' to continue."
        
        MsgBox strMsg
            
        strEmailAdd = Me.fld_ON_Recommend_Member & k_EMAIL
            
        strSubject = "Notification/Request - Overnight car booking"
        
        strMessage = strMessage & "Car : " & Me.fld_Car_ID.Column(1) & vbLf & vbLf
        
        strMessage = strMessage & "Booked for overnight use by : " & Me.fld_Driver & vbLf
        strMessage = strMessage & "From " & Me.fld_Date_From & " " & Format(Me.fld_Time_From, "hh:nn") & " to " & Me.fld_Date_To & " " & Format(Me.fld_Time_To, "hh:nn") & ".   " & vbLf
        strMessage = strMessage & "Reason : " & Me.fld_Reason & vbLf
        strMessage = strMessage & "Key Code : " & Me.fld_ON_KeyCode & vbLf
        strMessage = strMessage & "Garaged : " & Me.fld_ON_Garaged.Column(1) & vbLf
        strMessage = strMessage & "Security : " & Me.fld_ON_Security.Column(1) & vbLf
        strMessage = strMessage & "Special conditions : " & Me.fld_ON_SpecialConditions
        
        SendMail strEmailAdd, strSubject, strMessage
        
    Exit_Code:
        Exit Sub
        
    Error_In_Code:
        MsgBox "NotifyOvernight() " & Err.Number & " " & Err.Description
        Resume Exit_Code
        
    End Sub

    The following could easily be incorporated in the above.


    Code:
    Sub SendMail(pStrEmailAddress As String, pStrEmailSubject As String, pStrEmailMsg As String)
    On Error GoTo Error_In_Code
    
    
        'Provides the Send Mail automation
         'EMAIL USER DETAILS & ATT REPORT
        DoCmd.SendObject , , acFormatRTF, pStrEmailAddress, , , pStrEmailSubject, pStrEmailMsg, False, False
            
    Exit_Code:
        Exit Sub
        
    Error_In_Code:
        MsgBox "SendMail() " & Err.Number & " " & Err.Description
        Resume Exit_Code
    End Sub
    Hope this helps.

    Steve.

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

Similar Threads

  1. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  2. Replies: 1
    Last Post: 05-01-2014, 11:37 AM
  3. Replies: 22
    Last Post: 04-24-2014, 01:56 PM
  4. Replies: 13
    Last Post: 11-07-2012, 03:14 PM
  5. Replies: 6
    Last Post: 06-26-2012, 12:16 PM

Tags for this Thread

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