Results 1 to 3 of 3
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Count of equal item in a set

    I have a thread in the Query part of the site - https://www.accessforums.net/showthread.php?t=69823

    I think this needs to be done in VBA.

    I need to count of the number of times LIN=XXB804 in each platform.

    Code:
    X=0
    For X=X+1
    Code
    Next X
    If I make this query for the attached Access db: Counting4.accdb



    Code:
    SELECT Data.Platform, Data.LinName, Data.SequenceFROM Data
    WHERE (((Data.LIN)="XXB804"))
    ORDER BY Data.Platform;;
    I get:
    Platform..LINName..Sequence
    11321.....VRC-117
    11321.....VRC-117
    11321.....VRC-117
    12321.....VRC-117

    How do I get the sequence field filled in as:

    Platform..LINName..Sequence
    11321.....VRC-117...1
    11321.....VRC-117...2
    11321.....VRC-117...3
    12321.....VRC-117...1
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    That isn't just calculating a count - a simple aggregate GROUP BY query could do that. What you show is a sequence identifier, AKA row number - not easy to do in query.

    Not sure what level you want to do the sequence count. According to data in table, each platform can have multiple LINName values. Your posted example does not reflect that.

    Could generate it in a report using textbox RunningSum property.

    A query could use DCount(), like:

    SELECT Data.Platform, Data.LinName, DCount("*","Data","Platform='" & [Platform] & "' AND LinName='" & [LinName] & "' AND ID<" & [ID])+1 AS Seq
    FROM Data
    ORDER BY Data.Platform, Data.LinName, DCount("*","Data","Platform='" & [Platform] & "' AND LinName='" & [LinName] & "' AND ID<" & [ID])+1;
    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.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    June7,
    Thanks, Now I have to figure out what the code is doing. What you did was the first step.

    I modified it to look at the Parent and count. This it counts all the 117s, then counts all the 155's on the platform, then count the channel number assigned to the 155's

    Code:
    DCount("Unique","Data","Parent='" & [Parent] & "' AND Lin='" & [Lin] & "' AND ID<" & [ID])+1
    Thanks!!

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

Similar Threads

  1. Replies: 7
    Last Post: 11-29-2015, 07:24 AM
  2. Replies: 8
    Last Post: 01-29-2014, 12:56 PM
  3. Count totals per item from different tables
    By dgaletar in forum Queries
    Replies: 14
    Last Post: 02-25-2013, 09:36 AM
  4. Parent Item / Child Item Not Saving Correctly Together
    By Evilferret in forum Programming
    Replies: 6
    Last Post: 08-24-2012, 02:30 PM
  5. Replies: 7
    Last Post: 10-25-2011, 08:32 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