Results 1 to 5 of 5
  1. #1
    am465 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2

    Insert a Sequence Number in Query

    I would like to insert a sequence number into a query that currently returns 7367 rows.

    Here's what it looks like now:

    ID_NUM
    DTE_FIN_TRANS_RCV
    1322 9/27/2012
    1322 7/10/2012
    1011 7/2/1999
    1011 9/22/1999
    1011 10/21/1999


    Here's the desired outcome with sequences:

    ID_NUM
    DTE_FIN_TRANS_RCV
    SEQUENCE


    1322 9/27/2012 1
    1322 7/10/2012 2
    1011 7/2/1999 1
    1011 9/22/1999 2
    1011 10/21/1999 3


    All I need is a way to number rows with a value higher than the previous for that particular ID_NUM. Any assistance with achieving this will be most appreciated. Thank you.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Here is one way to do it.

    SELECT MyTable.ID_NUM, MyTable.DTE_FIN_TRANS_RCV, DCount(ID_NUM,"MyTable","ID_NUM=" & MyTable.[ID_NUM] & " AND MyTable.DTE_FIN_TRANS_RCV <= #" & MyTable.DTE_FIN_TRANS_RCV & "#") AS SEQUENCE
    FROM MyTable;

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    What do you need that sequence number for?

    Textbox in report has RunningSum property that can be used to accomplish the same.
    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.

  4. #4
    am465 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2
    Thank you. This is working perfectly. I'm finding some cases where the sequence starts at 2 when duplicate rows exist. Is there a way to have it start at 1 in those cases? I tried grouping it to just display the last but that bogged it down. Here's an example of what it's doing:

    Current Output

    ID_NUM DTE_FIN_TRANS_RCV SEQUENCE
    1650 9/17/2011 3
    1650 6/05/2011 2
    1650 6/05/2011 2

    Desired Output

    ID_NUM DTE_FIN_TRANS_RCV SEQUENCE
    1650 9/17/2011 3
    1650 6/05/2011 2
    1650 6/05/2011 1

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Need another field that makes the records unique.

    Review http://allenbrowne.com/ranking.html

    Otherwise, use report.
    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.

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

Similar Threads

  1. Show next number in sequence
    By cbrsix in forum Programming
    Replies: 1
    Last Post: 08-15-2013, 04:09 PM
  2. Insert sequence of numbers in table
    By amrut in forum Queries
    Replies: 2
    Last Post: 05-09-2013, 07:00 AM
  3. Replies: 3
    Last Post: 02-01-2013, 07:09 PM
  4. Find First number in sequence of numbers
    By losstww in forum Queries
    Replies: 4
    Last Post: 11-16-2012, 02:44 PM
  5. Enter new number in sequence in PO
    By tchirpich in forum Access
    Replies: 30
    Last Post: 12-30-2011, 11:24 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