This code has worked in multiple database I have already, but when I put it into the database I'm working on currently it will not compile.
Is it possible I unchecked something in the options and now it doesn't recognize something in the code?
Errors at Dim MyDB As DAO.Database
Error states:
Compile Error: User-defined type not defined.
Code:
Option Compare Database Option Explicit Private Sub E_Mail_Daily_Report_Click() Dim strEMail As String Dim oOutlook As Object Dim oMail As Object Dim strAddr As String Dim MyDB As DAO.Database Dim rstEMail As DAO.Recordset Dim strReportName As String Set oOutlook = CreateObject("Outlook.Application") Set oMail = oOutlook.CreateItem(0) strReportName = "RptDailyReport" DoCmd.OutputTo acOutputReport, "RptDailyReport", acFormatPDF, CurrentProject.Path & _ "\" & strReportName & ".pdf", False, , , acExportQualityPrint 'Retrieve all E-Mail Addresses in tblEMailAddress Set MyDB = CurrentDb Set rstEMail = MyDB.OpenRecordset("Select * From TblEmail", dbOpenSnapshot, dbOpenForwardOnly) With rstEMail Do While Not .EOF 'Build the Recipients String strEMail = strEMail & ![EmailAddress] & ";" .MoveNext Loop End With '-------------------------------------------------- With oMail .To = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ; .Body = "Please review the attached report." .Subject = "Daily Retest Report" .Display .Attachments.Add CurrentProject.Path & "\" & strReportName & ".pdf" End With Set oMail = Nothing Set oOutlook = Nothing rstEMail.Close Set rstEMail = Nothing Dim aFile As String aFile = "N:\Lab\Underwater Retest Daily Reports\Daily Report.pdf" If Len(Dir$(aFile)) > 0 Then Kill aFile End If End Sub
Errors at Dim MyDB As DAO.Database
Error states:
Compile Error: User-defined type not defined.
Comment