I have used this info to write some code behind a button on a form which sends an email. However, my set up is slightly different as I am using frm_Email with a subform Frm_EmailCOntent. This is the only way I can think to do this as I need to get access to the email address from tbl_client and want to save the email info into tbl_comms. So from my Frm_Client I open up Frm_email and I can see it is pulling in fields ClientID and Email1 from tbl_client nicely and the subform from tbl_comms is set to data entry waiting for the new information. Once I enter some comms info I run the code below behind my button which resides in Frm_EmailCOntent but it has a problem identifying the Email1 - I think this is because it is in Frm_Email. Have I referenced it incorrectly?
Private Sub SendEmail_Click()
Dim strEmail, strsubject, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'**************************************************************
'*create string with email address
[highlight #FCE94F]strEmail = [frm_email]![Email1][/highlight]strsubject = Me.Summary
strBody = Me.Notes
'***creates and sends email
With objEmail
.To = strEmail
.subject = strsubject
.Body = strBody
.Send
End With
Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
'objOutlook.Quit
Exit Sub
End Sub
Private Sub SendEmail_Click()
Dim strEmail, strsubject, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'**************************************************************
'*create string with email address
[highlight #FCE94F]strEmail = [frm_email]![Email1][/highlight]strsubject = Me.Summary
strBody = Me.Notes
'***creates and sends email
With objEmail
.To = strEmail
.subject = strsubject
.Body = strBody
.Send
End With
Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
'objOutlook.Quit
Exit Sub
End Sub