In each group, fill the first row with a 0, and the successive rows with a 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chopin
    New Member
    • Mar 2007
    • 37

    In each group, fill the first row with a 0, and the successive rows with a 1

    Let's say I have groups of data. In each group, I want the first row to be filled with a 0, but each successive row with 1's.

    Here is an example of data output:

    Account, Date, Yes/No
    account1, 1/1/2008, 0
    account1, 4/5/2009, 1
    account1, 3/4/2010, 1
    account1, 7/7/2011, 1
    account2, 1/6/2008, 0
    account2, 3/3/2009, 1
    account2, 4/4/2010, 1
    account5, 2/3/2008, 0
    account5, 5/3/2009, 1
    account5, 4/3/2010, 1
    account5, 3/4/2011, 1

    etc...

    I'm not sure if the min, or first function can be used to accomplish this, but there must be a way. Thanks for any help!
  • chopin
    New Member
    • Mar 2007
    • 37

    #2
    I was able to figure this out with the following logic in DAO (I'm just going to enter in quick human readable code. Since my project is actually a little different than what I had asked, I don't want to confuse you all with code that may not make sense unless you know my project.)

    Code:
    Do Until rst.EOF
    If Account = AccountPrevious Then "1", Else "0"
    Loop
    DAO is a nightmare to learn, but I discovered the "step into" function today, and this really helps the debugging process.

    Comment

    Working...