Results 1 to 4 of 4
  1. #1
    MikeDub is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    2

    Access2010 - email automation (if not NULL)

    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
    ...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You could test with a DCount() against the report's source, using the same criteria. Only go forward if it's greater than 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MikeDub is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    2
    Thanks for your time and feedback. That worked really well!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Email automation run-time error 2147467259
    By goestejs in forum Access
    Replies: 6
    Last Post: 06-19-2014, 02:00 PM
  2. Access2010 accdb conversion to SQL
    By boss1b in forum SQL Server
    Replies: 9
    Last Post: 10-15-2012, 02:04 PM
  3. Adding a logo to an email that is being sent through Access2010
    By crowegreg in forum Import/Export Data
    Replies: 3
    Last Post: 04-22-2012, 09:28 PM
  4. Replies: 3
    Last Post: 12-02-2010, 12:23 PM
  5. Access2010 problem with .close
    By jong in forum Access
    Replies: 1
    Last Post: 11-18-2010, 12:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums