I am trying to send a report via email that is in the body of the email not an attachment. In addition, I only want the current record sent, and not the entire database. Every time I run it, however, I get an error message that says "An expression you entered is the wrong data type for one of the arguments" I know I am missing something, but I cannot see it. Can someone help? Thanks. Here is my code.
Private Sub Command350_Click()
On Error GoTo Err_Command350_Click
Dim strDocName As String
Dim strWhere As String
strDocName = "IncidentReport"
strWhere = "[IntakeID]=" & Me!IntakeID
Me.Refresh
DoCmd.OutputTo acOutputReport, strDocName, acFormatHTML, "c:\myreport.html", , , strWhere
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.To = "Forms!IncidentForm!btEmail"
.Subject = "Incident Report"
.BodyFormat = olFormatHTML
.HTMLBody = "C:\myreport.html"
.Display
End With
Exit_Command350_Click:
Exit Sub
Err_Command350_Click:
MsgBox Err.Description
Resume Exit_Command350_Click
End Sub
Private Sub Command350_Click()
On Error GoTo Err_Command350_Click
Dim strDocName As String
Dim strWhere As String
strDocName = "IncidentReport"
strWhere = "[IntakeID]=" & Me!IntakeID
Me.Refresh
DoCmd.OutputTo acOutputReport, strDocName, acFormatHTML, "c:\myreport.html", , , strWhere
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.To = "Forms!IncidentForm!btEmail"
.Subject = "Incident Report"
.BodyFormat = olFormatHTML
.HTMLBody = "C:\myreport.html"
.Display
End With
Exit_Command350_Click:
Exit Sub
Err_Command350_Click:
MsgBox Err.Description
Resume Exit_Command350_Click
End Sub