Results 1 to 3 of 3
  1. #1
    DBDave is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    6

    How to get count of filtered records


    Hi. I have a command button on my search form which opens another search results form using the following:

    DoCmd.OpenForm "frmSearchResults", acNormal, , Replace(BuildFilter, "WHERE", ""), , acDialog

    it works great however I don't want to open the search results form if there are no records because that throws a runtime error for the user. The search results form is based on a query, but the query only serves to select which fields are to be displayed. The form gets filtered not based on the query, but on the form's Filter property which contains the value of BuildFilter.

    How can I test whether there are any results before opening the form? I looked at DoCmd.OpenQuery but it doesn't look like it accepts a filter. I'm sure this is easy but beyond my current skills.

    Thanks.

  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 could use a DCount() with the same criteria.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Bing: Access vba cancel form open if no data

    http://bytes.com/topic/access/answer...3-no-data-form
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 03-29-2014, 01:29 AM
  2. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  3. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  4. Exporting Pivot Table to Excell - only want filtered records
    By Jennifer227 in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2011, 03:10 PM
  5. Open form to filtered records
    By ducecoop in forum Access
    Replies: 3
    Last Post: 10-22-2010, 10:53 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