Hi I have the below code which I took from a tutorial which looked to work well.
I have this behind an command button.
The issue is I get the following error:
The expression On Click you entered as the event property setting produced the following error: Object variable or WIth block variable not set.
The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
There may have been an error evaluating the function, event, or macro.
This is happening on a access runtime as the company who have my database do not have a full ms access version.
Private Sub Command6_Click()
Dim Msg As String
Msg = "Dear Business Support,<P>" & _
"A New Accident has been recorded in the Accidents Database for you to review."
Dim O As Outlook.Application
Dim M As Outlook.MailItem
Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)
Set M = Nothing
Set O = Nothing
With M
.BodyFormat = olFormatHTML
.HTMLBody = Msg
.To = "bss@seabrookgroup.com"
.Subject = "New Accident Report " & Now()
.Send
End With
DoCmd.OpenForm "FrmTodaysRecords"
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub