Results 1 to 4 of 4
  1. #1
    teirrah1995 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2010
    Posts
    35

    Count + between + parameter function

    Title makes no sense.



    I have a field, TestDate, and I want to count the number of patients whose TestDate is between xx/xx/xxxx and xx/xx/xxxx. I want the query to ask me for those two dates.

    This is what I have so far:
    SELECT COUNT(TestDate) AS Tested
    FROM Patient (My Table)
    WHERE TestDate='BETWEEN [Between?] AND [And?]';

    When I open the query, it asks TestDate and gives a value of 0 whatever I put in. Could someone tell me what I'm doing wrong, please?
    I've never used SQL before, so it would be great if someone knew a good site where I can learn about it.

  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,518
    Does this work?

    SELECT COUNT(TestDate) AS Tested
    FROM Patient (My Table)
    WHERE TestDate BETWEEN [Between?] AND [And?]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    teirrah1995 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2010
    Posts
    35
    Thanks, I've removed the quotes and it works spiffingly. It's always things like that which I get caught on. Thank you!

  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,518
    Happy to help. You also had an equals sign in there that would cause a problem. It's either = or Between, not both.
    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. Question; Count function ..
    By efleming in forum Queries
    Replies: 4
    Last Post: 05-27-2011, 08:05 AM
  2. Access function to count records
    By mbaptista1970 in forum Access
    Replies: 6
    Last Post: 01-07-2011, 09:50 AM
  3. Count function on query
    By yousillygoose in forum Queries
    Replies: 1
    Last Post: 02-15-2010, 09:58 PM
  4. Count function in Query always Read Only?
    By terbs in forum Queries
    Replies: 3
    Last Post: 01-19-2010, 05:43 PM
  5. Query using count function
    By wasim_sono in forum Queries
    Replies: 0
    Last Post: 11-28-2007, 03:16 AM

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