M
mchapman44
I have a form that contains many sub forms within it. I'm trying to setup VB
code to send information within these forms to MS Outlook. My email code is
working and I can select fields from the master form (The Form that opens)
but I cannot get data from the sub forms. I believe it's because my VB is not
selecting the correct record source from the form.
My sub form name is 'Sub_Frm_Finance' and I need to select data from 7
fields from this form.
My VB code so far is below. When I run the code I get a compile error on the
'RecordsetClone' value!!!!
Private Sub Email_Click()
Dim mess_body As String
Dim rst As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Set rst = Sub_Frm_Finance.RecordsetClone
mess_body = "Booking Number" & Me.BookingNumber & vbCrLf & "Job Title" &
rst!JobTitle & vbCrLf & "Job Location" & rst!JobLocation & vbCrLf & "CRB
Check Required" & Me.CRBRequired & "Start Date" & rst!JobStartDate & " " &
"End Date" & rst!JobEndDate & vbCrLf & "StartTime" & rst!StartTime & vbCrLf &
" " & "End Time" & rst!EndTime & vbCrLf & "Required Hours" &
rst!RequiredHours & vbCrLf & "Required Days" & rst!RequiredDays & vbCrLf &
rst!Comments
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Set the Subject, the Body, and the Importance of the e-mail message.
.To = "(e-mail address removed)"
.Subject = "Job Alert"
.Body = mess_body
.Display
End With
End Sub
I would greatful if someone could help as I need to finish the database by
the end of the week and this is my last section.
code to send information within these forms to MS Outlook. My email code is
working and I can select fields from the master form (The Form that opens)
but I cannot get data from the sub forms. I believe it's because my VB is not
selecting the correct record source from the form.
My sub form name is 'Sub_Frm_Finance' and I need to select data from 7
fields from this form.
My VB code so far is below. When I run the code I get a compile error on the
'RecordsetClone' value!!!!
Private Sub Email_Click()
Dim mess_body As String
Dim rst As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Set rst = Sub_Frm_Finance.RecordsetClone
mess_body = "Booking Number" & Me.BookingNumber & vbCrLf & "Job Title" &
rst!JobTitle & vbCrLf & "Job Location" & rst!JobLocation & vbCrLf & "CRB
Check Required" & Me.CRBRequired & "Start Date" & rst!JobStartDate & " " &
"End Date" & rst!JobEndDate & vbCrLf & "StartTime" & rst!StartTime & vbCrLf &
" " & "End Time" & rst!EndTime & vbCrLf & "Required Hours" &
rst!RequiredHours & vbCrLf & "Required Days" & rst!RequiredDays & vbCrLf &
rst!Comments
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Set the Subject, the Body, and the Importance of the e-mail message.
.To = "(e-mail address removed)"
.Subject = "Job Alert"
.Body = mess_body
.Display
End With
End Sub
I would greatful if someone could help as I need to finish the database by
the end of the week and this is my last section.