Results 1 to 4 of 4
  1. #1
    warrigal is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2011
    Location
    Qld, Australia
    Posts
    5

    Auto email query

    Hey all



    I have set up a number of queries that are run once a week and the results are emailed to various people. However these queries are ones that will always return results. I now have a query that will not always return results. I would only like to send an email if the query returns results. I still run it each day automatically, checking for due dates within 2 days of the current date.

    Cheers

  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,640
    You can use DCount() to test the query, and only send the email if the result is >0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    warrigal is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2011
    Location
    Qld, Australia
    Posts
    5
    Thanks Paul, still having issues.

    I created a DCount expression in the query I am running using the due date as the expr and the table name as the domain. I haven't used any criteria (not sure if this is correct). There are 2 records that come up (which is fine and correct) but the count is 2659 for both of the records. I am unsure where this number comes from...

  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,640
    Well, you probably don't have a criteria on the DCount. However, I didn't mean to include it in the query. In the code where you're sending the emails:

    Code:
    If DCount("*", "QueryName") > 0 Then
      'your code to send the email
    End If
    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. Query displayed as body of email - edit
    By virnier in forum Access
    Replies: 0
    Last Post: 03-16-2011, 01:26 PM
  2. Replies: 1
    Last Post: 03-09-2011, 08:54 AM
  3. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM
  4. Email from report to Email body
    By Ehmke66 in forum Programming
    Replies: 4
    Last Post: 01-03-2011, 01:06 PM
  5. Email Query Results
    By eddie_keating in forum Queries
    Replies: 1
    Last Post: 06-16-2010, 11:09 AM

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