Results 1 to 4 of 4
  1. #1
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2014
    Posts
    81

    VBA to Email Filtered Report to Addresses Listed on Table

    I have found a number of threads on this topic, but none of them seem to have been solved or are doing something a little different. I’ll try to keep it simple.

    I want to email a report so that each recipient will receive a pdf of only the section of the report that is related to them. I have a table with manager information tblManager. This table has the fields: ID, Team, FirstName, LastName, Phone, Email. I also have a report called rptMonthlyUpdate

    My goal is to use vba code to email each manager a filtered report that shows only the information related to their team. Here is the code I attempted. It obviously isn’t working. Any suggestions?

    Private Sub btnSendReport_Click()
    DoCmd.SendObject acSendReport, "rptMonthlyUpdate", acFormatPDF, DLookup("[Email]", "[tblManager]", "[Team]=" & [Team]), , , "Monthly Report", "Attached is a copy of the monthly report."

    End Sub

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    No, it's not real obvious. Maybe the report isn't being attached? Maybe the DLookup isn't working because Team is a string and not a number? Maybe the email isn't being generated? What you have won't filter the report, so is that the part that "isn't working"?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In order to use that method, you either have to have the report's source query use the form for a criteria, or open the report filtered using the method below, email it, then close the report. Nothing in your code would filter it.

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    There's no field in the dlookup statement?

    And as pbaldy says you have no filter on the report (only who it goes to)


    Sent from my iPhone using Tapatalk

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

Similar Threads

  1. Duplicate email addresses in a report
    By Mike Y in forum Reports
    Replies: 7
    Last Post: 04-08-2016, 08:19 AM
  2. Send email using CDO, get email addresses from table
    By marvinac1 in forum Programming
    Replies: 3
    Last Post: 12-22-2014, 12:54 PM
  3. Replies: 3
    Last Post: 08-16-2013, 04:15 PM
  4. How to send filtered report via email
    By degras in forum Reports
    Replies: 4
    Last Post: 03-31-2011, 09:09 AM
  5. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM

Tags for this Thread

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