Email specific record from a form (1 Viewer)

FahadAlAmri

New member
Local time
Today, 15:31
Joined
Oct 31, 2014
Messages
3
In Access 2010 I have built a FORM which has several records of several people. I am trying to email one record only to a certain person from that FORM. If I use the access email button it opens outlook but it sends all the records in the FORM to the person. I have tried even to use the micro, but still it attach all the records in the FORM and send it all as one bundle to other.

I do not want that. These are private assignment records. Can someone help me and guide me to the correct way to send only one record from the FORM. how to do it.
 

Minty

AWF VIP
Local time
Today, 23:31
Joined
Jul 26, 2013
Messages
10,371
How is the button working? what is the code that runs when the button is pressed?
Is the button on the form header or in the detail section?
 

FahadAlAmri

New member
Local time
Today, 15:31
Joined
Oct 31, 2014
Messages
3
How is the button working? what is the code that runs when the button is pressed?
Is the button on the form header or in the detail section?


When I press the button it goes to outlook email fine but it attach the whole form. I need only to attach a certain record from the form not the whole form
 

burrina

Registered User.
Local time
Today, 17:31
Joined
May 10, 2014
Messages
972
When you say Record, what do you mean? A few select fields or what?
I don't use Outlook. If you do a Google search or look on this forum for sample db's you will find a lot of help.
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 08:31
Joined
Oct 20, 2008
Messages
512
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.
 
Last edited:

FahadAlAmri

New member
Local time
Today, 15:31
Joined
Oct 31, 2014
Messages
3
When you say Record, what do you mean? A few select fields or what?
I don't use Outlook. If you do a Google search or look on this forum for sample db's you will find a lot of help.


I have a form for all my students work, i named it TaskAssignmentForm. Each entry in the form creates a record for a particular ID and store it in a table. So I need to email only that particular record with all related fields only. For example John name, john title, john assignment, Due date date, memo all related to John only, I need to email John record only and not any one else.

When I use email while I am in the Form environment as a PDF,it actually emails all the records in the form. I need only to email one record and no other record to my student

How to do it.
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 08:31
Joined
Oct 20, 2008
Messages
512
I have a form for all my students work, i named it TaskAssignmentForm. Each entry in the form creates a record for a particular ID and store it in a table. So I need to email only that particular record with all related fields only. For example John name, john title, john assignment, Due date date, memo all related to John only, I need to email John record only and not any one else.

When I use email while I am in the Form environment as a PDF,it actually emails all the records in the form. I need only to email one record and no other record to my student

How to do it.

See post #6, those procedures achieve what you are asking. Modify for your purposes.
 

themurph2000

Fat, drunk, and stupid
Local time
Today, 17:31
Joined
Sep 24, 2007
Messages
181
I second essaytee, because it sounds like what Fahad needs. Fahad, is the item you want emailed on the screen in a single form? If so, the solution here works because you email the contents of each of the individual bound text boxes that would be on your form. If those boxes don't have names to them, name them first (txtThisBox, txtThatBox, whatever). Then that should make essaytee's code very easy to adapt. I should know; I just used it.

To that end, I did have one question. Is there any way to format the static text (between the quotes) for the email to be bolded or italicized? I've seen the SendObject command used before, but I had not seen anyone able to bold or italicize any of the text. There are other formats that can do it, but I like yours because it bypasses any actual use of Microsoft Outlook.
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 08:31
Joined
Oct 20, 2008
Messages
512
...snip...

To that end, I did have one question. Is there any way to format the static text (between the quotes) for the email to be bolded or italicized? I've seen the SendObject command used before, but I had not seen anyone able to bold or italicize any of the text. There are other formats that can do it, but I like yours because it bypasses any actual use of Microsoft Outlook.

Sorry, can't assist with the formatting question. I'm currently in the process of upgrading from Access 2003 to 2010. In 2003 there were no Rich Text options available but I'm aware this is possible for 2010 but can't assist, at this time, with the implementation of it.

Steve.
 

Users who are viewing this thread

Top Bottom