Results 1 to 4 of 4
  1. #1
    sarah1970 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2017
    Posts
    2

    If query results are greater than 20 then run another query


    I need to run a separate query if my query results total is greater than 20 but if there are more than 20 I just need all records to show. The second query will pull a random 5% if there are more than 20 records.

  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,521
    A DCount() with no criteria will return the number of records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sarah1970 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2017
    Posts
    2
    Quote Originally Posted by pbaldy View Post
    A DCount() with no criteria will return the number of records.
    Great but I need to find out if the query results are greater than 20 and if they are then run a different query to randomize records but if it's less than 20 I want to bypass the query to randomize and display all the records.

  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,521
    Code:
    If DCount(...) > 20 Then
      run one query
    Else
      run the other
    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. Greater Than in Query
    By rplum in forum Queries
    Replies: 7
    Last Post: 04-19-2016, 09:33 AM
  2. Replies: 5
    Last Post: 03-12-2015, 05:13 AM
  3. Replies: 11
    Last Post: 04-11-2014, 04:26 PM
  4. Replies: 1
    Last Post: 04-10-2014, 12:55 PM
  5. Greater than query
    By noobaccess in forum Access
    Replies: 5
    Last Post: 12-05-2012, 09:18 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