Results 1 to 4 of 4
  1. #1
    dbhokie is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    12

    How to count the number of records in a field in a query that have same name

    Example:

    Type Sub Type Size
    A X 1
    B Z 3
    A Y 1
    C Z 2
    D X 1
    B X 3
    C Y 2
    A Z 1
    D Z 2

    Lets Say this is table [Products]
    There are 3 types of Products with different types subtypes and sizes

    What I am trying to do is make a query (or multipe nested queries if neccesary) or anything that will work to my purpose. I confess, this is beyond what I would normally try with Access, I considered filtering but I thought there must be an easier way. Then I tried to understand Dcount, but was only able to make it work in VBA, and all of the examples I tried in a query I just could not get to work. So back to scratch.

    What I want to get the number of A's, B's, C's and D's in the column and then the combinations of unique types of inventory
    A=3
    B=2
    C=2
    D=2
    AY=1
    AZ=1


    AX=1
    BZ=1
    BX=1
    CZ=1
    CY=1
    DX=1
    DZ=1
    AX1=1
    AY1=1
    Etc. In my table there are a thousand objects with quite a few combinations (eg: the size field has about 12 unique sizes), however this should convey the idea I think.

    Could anyone give me an idea of how to go about this?

    I greatly appreciate your time in this matter and apologize for myself :P

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I think you need totals queries in which you group by Type and Select Count for the ProductID for the first one, group by Type and SubType and Count the ProductID, etc.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I agree with Vlad. Here's part to get you started.

    SELECT Hokie.Type, Count(Hokie.Type) AS CountOfType
    FROM Hokie
    GROUP BY Hokie.Type;

    Type CountOfType
    A 3
    B 2
    C 2
    D 2


    SELECT [Type] & [Hokie]![Sub Type] AS TS, Count([Type] & [Hokie]![Sub Type]) AS TSc
    FROM Hokie
    GROUP BY [Type] & [Hokie]![Sub Type];

    TS TSc
    AX 1
    AY 1
    AZ 1
    BX 1
    BZ 1
    CY 1
    CZ 1
    DX 1
    DZ 1

  4. #4
    dbhokie is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    12
    I never said, but thank you both very much for your help. @orange , This worked perfectly!

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

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2017, 08:21 AM
  2. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  3. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  4. count the number of records from a query
    By Nixx1401 in forum Queries
    Replies: 4
    Last Post: 05-24-2011, 06:45 PM
  5. Replies: 7
    Last Post: 07-22-2010, 01:14 PM

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