Good day,
I'm attempting to use Access to automate reporting emails and I'm trying to identify the best way to identify if the report is NULL (blank).
Any suggestions or feedback would be greatly appreciated. Thanks in advance!
VBA:
(strReportName is set to the report. Employees is set to the Employee Name. Email is set to the employees email address. [Requested By] is the column in the report that is used as a filter. The code is functional but also emails reports that are blank. I'm trying to just send the ones that have data)
...
strOutputPath = CurrentProject.Path & "\" & strReportName & "'" & Employees & "'" & ".pdf"
DoCmd.OpenReport strReportName, acViewPreview, , "[Requested By]=" & "'" & Employees & "'"
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strOutputPath
DoCmd.Close acReport, strReportName, acSaveNo
Set appOutlook = CreateObject("Outlook.Application")
Set objMailItem = appOutlook.CreateItem(0) ' olMailItem
With objMailItem
.Subject = Employees & " - Open POs"
.To = email
.Attachments.Add strOutputPath
.Close (0) ' olSave
.Display
'.Send
End With
...