Results 1 to 3 of 3
  1. #1
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169

    Create a sequence number for each record associated to a foreign key

    Hi,


    I am hoping somebody can help me with this. I have data in a table that looks like the first table and I would like to write a query to update the sequence so it looks like the second table. Any ideas?

    PersonID Color Sequence
    1 Red
    1 Blue
    1 Green
    2 Blue
    3 Red
    3 Blue

    PersonID Color Sequence
    1 Red 1
    1 Blue 2
    1 Green 3
    2 Blue 1
    3 Red 1
    3 Blue 2

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Is there a specific reason you want the sequence in the table?
    Access has built-in functionality that will allow you to do running counts over groups in a Report.

    I don't know if it is possible to do running counts over groups in a query in Access.
    You COULD write those values to the table using a recordset in VBA code.

  3. #3
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Thanks for the reply. I was actually needing the sequence so I could run a cross tab query with the sequence number as a column heading. I decided to take a different approach and just export the table into excel and use the function =if(A1=A2, B1+1, 1) and then imported the table back into access. That was faster than trying to figure out the correct VBA. Thanks again.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-07-2012, 08:21 AM
  2. Enter new number in sequence in PO
    By tchirpich in forum Access
    Replies: 30
    Last Post: 12-30-2011, 11:24 AM
  3. how to auto inset sequence number at column
    By newaccess in forum Access
    Replies: 1
    Last Post: 04-01-2011, 06:55 PM
  4. Find Missing Number in Sequence per Record
    By escuro19 in forum Programming
    Replies: 1
    Last Post: 11-10-2009, 03:15 PM
  5. Auto Sequence String Serial Number
    By eddyc99 in forum Programming
    Replies: 2
    Last Post: 10-02-2009, 08:11 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