Results 1 to 8 of 8
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287

    Running sum, by product? Autonumber, by product?

    Hey guys,

    I have an output that lists a package sku and its components. Each component get its own record. What I need is to autonumber by package sku, like this:
    Click image for larger version. 

Name:	Screen Shot 2015-04-30 at 12.13.23 PM.png 
Views:	12 
Size:	23.2 KB 
ID:	20545

    I have seen things about somehow creating a temp table, and using autonumber on that temp table, then appending that data to a master table, and doing that for each package. I was also thinking of making a column of all 1's and just doing a running total (DSum?) but only by each package sku.

    We have 12k package sku's, so obviously I can't do this by hand..

    Any ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Review http://allenbrowne.com/ranking.html

    Can probably also be done with DCount() but domain aggregate functions can be slow, although I have known the subquery approach to run slow as well on large datasets.

    Record 7 in the example doesn't seem to fit. Why does it show 4 under What I Need?
    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
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Quote Originally Posted by June7 View Post
    Review http://allenbrowne.com/ranking.html

    Record 7 in the example doesn't seem to fit. Why does it show 4 under What I Need?

    Typo, did that really fast while the bosses were trying to rush me out the door.

    I am fully expecting this to run slow, but I will only have to do it once. This is all for a conversion from our old system to the new.

    I'll go over that Ranking page and see if I can get it to work.

    Thanks

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Updating a new field can also probably be done programmatically by opening and manipulating a recordset of the table.
    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.

  5. #5
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Quote Originally Posted by June7 View Post
    Updating a new field can also probably be done programmatically by opening and manipulating a recordset of the table.
    That is where you lose me. Only messed with recordsets in VBA a couple times and it was just over my head.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Code like:
    Code:
    Public Sub SetPackSeq()
    Dim rs As DAO.Recordset
    Dim strPKG As String, intSeq As Integer
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM Table1 ORDER BY PKG_ITM_CD, CMPNT_ITM_CD;")
    strPKG = rs!PKG_ITM_CD
    intSeq = 1
    While Not rs.EOF
        rs.Edit
        If rs!PKG_ITM_CD <> strPKG Then
            strPKG = rs!PKG_ITM_CD
            intSeq = 1
        End If
        rs!WhatINeed = intSeq
        rs.Update
        intSeq = intSeq + 1
        rs.MoveNext
    Wend
    End Sub
    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.

  7. #7
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    That worked perfectly on a test sample. Wow.

    Bout to test on main database.

  8. #8
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Looks good! Thank you so much!! The skill and knowledge that some of you guys have just blows me away.

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

Similar Threads

  1. Replies: 6
    Last Post: 02-28-2015, 11:57 AM
  2. Replies: 3
    Last Post: 01-18-2015, 06:05 PM
  3. Replies: 2
    Last Post: 08-14-2014, 11:49 AM
  4. Replies: 4
    Last Post: 04-26-2013, 08:32 AM
  5. Replies: 3
    Last Post: 02-26-2013, 05:07 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