Results 1 to 2 of 2
  1. #1
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64

    Open a report only if query has some records

    I have one button on a form that opens two reports (unconditionally). I'd like to have the button open two additional reports, but only on the condition that the record source for the two additional reports (both queries) has some records. So the button will open between 2 to 4 records depending on whether the queries for the two additional reports have any records. My question is how do I create a macro that only opens a report when its control source has records.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You don't really have to check for data. You can use the No Data event of the report and in it have:

    Cancel = True

    You will need to trap for the resulting error, so I'd use VBA code rather than a macro, and include error handling:

    http://www.baldyweb.com/ErrorTrap.htm
    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. Replies: 4
    Last Post: 06-03-2014, 10:30 AM
  2. Replies: 1
    Last Post: 06-03-2014, 06:56 AM
  3. Help on report to open form to open query...
    By saseymour in forum Programming
    Replies: 13
    Last Post: 07-16-2013, 08:11 AM
  4. Replies: 2
    Last Post: 05-26-2011, 12:15 PM
  5. open form if no records in query
    By MiaAccess in forum Forms
    Replies: 1
    Last Post: 03-05-2011, 12:11 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