I would like to use the following code that I found here on Experts Exchange. I have altered some for my needs. I get a compile error if I attempt to use this as an On Click Event. I have also copied and pasted this in a module to use it as a Private Function. I am not familiar with functions and how to call them or if you can even call them from an on click event. The compile error occurs at the "DIM appoutlook as new outlook application. I am using Access 2013. I appreciate any help with this.
Private Function SendPDFReport()
'Created by Helen Feddema 17-Jan-2010
'Last modified 17-Jan-2010
On Error GoTo ErrorHandler
Dim appOutlook As New Outlook.Application
Dim itm As Outlook.MailItem
Dim strFileName As String
Dim rpt As Access.Report
Dim strReport As String
Dim strCurrentPath As String
Dim strFileNameAndPath As String
strCurrentPath = "C:\users\13618\desktop\pdfs & " \ ""
strReport = "R_UnitCheckByEmp"
strFileName = Me.TxtFileName.pdf
strFileNameAndPath = strCurrentPath & strFileName
'Output report to PDF in current path
DoCmd.OutputTo objecttype:=acOutputReport, _
'Create new mail message and attach text file to it
Set itm = appOutlook.CreateItem(olMailItem)
.To = "email@example.com"
.Subject = "Daily report"
.Body = "Your message"
'To edit before sending
'To send automatically
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description