Results 1 to 4 of 4
  1. #1
    Tabix09 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    2

    Angry Count function grouping.

    Hi all, I was hoping I would be able to come here to get some help on a database I'm currently working on.

    I'm creating a rental system for a DvD shop and I need to figure out a few breakpoints to do with how long each customer can rent their share of DvDs.

    Depending on how many DvDs they rent, they get to have them for longer.

    < 5 DvDs = 2 nights.
    5-10 DvDs = 1 week
    > 10 DvDs = 2 weeks

    I wanted to use a count function to count how many DvDID's each RentalID has, use these numbers with an IIF function to find out what threshold it rests in and then use them with a date function and the RentalDate field to figure out when they need to be returned.

    I can't get the Count function to work in my query.

    I'm using a query with only RentalID (text), DvDID (text) and I want to use a count function but every time I try I keep getting 'You tried to excecute a query that does not include the specified expression'RentID' as part of an aggregate function'. This error also happens when I try something simple like Count([RentID]).

    If someone could be of assistance it would be greatly appreciated

    (even if you could give some tips for the next parts )



    Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Can you post the SQL statement of the query please
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Tabix09 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    2
    I have figured it out, but now it is counting doubles and being wierd (there is 9 DvDIDs for 1 of the RentalIDs and it is counting a 2 and a 7)

    SQL:


    SELECT Rental.[RentID], Count(Rental.[DvDID]) AS CountOfDvDID
    FROM Rental
    GROUP BY Rental.[RentID];

    That's one,

    SELECT [Rental Query].RentID, [Rental Query].CountOfDvDID, IIf([CountOfDvdID]>10,14,IIf([CountOfDvdID]>4 And [CountOfDvdID]<11,7,IIf([CountOfDvdID]<5,2))) AS Days
    FROM [Rental Query];

  4. #4
    Rhino373 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    65
    I'm betting your RentalID is somehow different than the first where it is grouping them seperately. This is especially possible since the datatype is text. Could be something as little as an extra space. I'd consider turning it into an AutoNumber.

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

Similar Threads

  1. Count + between + parameter function
    By teirrah1995 in forum Queries
    Replies: 3
    Last Post: 08-11-2011, 10:25 AM
  2. Question; Count function ..
    By efleming in forum Queries
    Replies: 4
    Last Post: 05-27-2011, 08:05 AM
  3. Access function to count records
    By mbaptista1970 in forum Access
    Replies: 6
    Last Post: 01-07-2011, 09:50 AM
  4. Count function on query
    By yousillygoose in forum Queries
    Replies: 1
    Last Post: 02-15-2010, 09:58 PM
  5. Query using count function
    By wasim_sono in forum Queries
    Replies: 0
    Last Post: 11-28-2007, 03:16 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