Results 1 to 6 of 6
  1. #1
    bmj121 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2012
    Posts
    3

    Running page count tied to volume number

    I have a form with a "Volume" field and a "Page" field and "Total" field. "Volume" is a book volume, so a volume contains several items that have "page" lengths. As each item is entered, the "Volume" field and "page" fields are entered. What I need is a set of code that will allow me to enter the total pages for the volume as each item is added.



    Example:

    Item# Volume# Pages Total
    Item #1: 1 3 3
    Item #2: 1 2 5
    Item #3: 2 2 2
    Item #4: 1 4 9
    Item #5: 2 2 4


    Hopefully you get the point. I know I'm coming to this with nothing to start with, and if you can only give me a piece of the puzzle, any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    That looks like a running sum over a group. This is an aggregate calculation. Saving aggregate data to table is not usually a good idea nor necessary. This calc is best done during output not data entry and can easily be done on reports. Textboxes on reports have a RunningSum property.

    Showing this calc on a form and saving to table with your data entry structure would involve VBA code.
    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
    bmj121 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2012
    Posts
    3

    OK, I'll bite

    Quote Originally Posted by June7 View Post
    That looks like a running sum over a group. This is an aggregate calculation. Saving aggregate data to table is not usually a good idea nor necessary. This calc is best done during output not data entry and can easily be done on reports. Textboxes on reports have a RunningSum property.

    Showing this calc on a form and saving to table with your data entry structure would involve VBA code.

    So ultimately, the page count is needed for a report, so running it in a report will work for me. The problem that I see is that I need a page start count for each item. And the page count for each item needs to appear in line with said item. I've done count totals on reports before, but I've only ever done them for the entire report or for each section. I've never had any luck getting counts for each item.

    I knew that getting the page count into the form would require VBA, and I'm working in that direction, hoping to use DLookup to write the information to a table and then retrieve the information.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The example shows a running total for each Volume#. To produce this in report the records would have to be grouped by Volume#. If you want to maintain order by Item#, that is a complication and a VBA procedure is probably the only solution.
    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
    bmj121 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2012
    Posts
    3

    First part of answer

    Quote Originally Posted by June7 View Post
    The example shows a running total for each Volume#. To produce this in report the records would have to be grouped by Volume#. If you want to maintain order by Item#, that is a complication and a VBA procedure is probably the only solution.
    Here'e the code that retrieves the information from a table I set up. Now I need to figure out how to get "NewPage" into the corresponding field "PageTotal" in the table StatPages, where "Volume" = "Volume" from the form. So, almost there.
    Private Sub Pages_AfterUpdate()
    MyVar = DLookup("PageTotal", "StatPages", "Volume = " & Nz([Volume], 0))
    Me![Start Page] = MyVar
    NewPage = MyVar + Me!Pages
    MsgBox NewPage
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If PageTotal field is included in the form's RecordSource, could be:

    Me!PageTotal = Me![Start Page] + Nz(DLookup("PageTotal", "StatPages", "Volume = " & [Volume]),0)
    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. Replies: 2
    Last Post: 09-16-2011, 06:11 PM
  2. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  3. Page number in reports
    By SFC in forum Access
    Replies: 2
    Last Post: 03-08-2011, 11:09 AM
  4. Running Count Query
    By monkey2003 in forum Queries
    Replies: 0
    Last Post: 09-21-2009, 12:24 PM
  5. Replies: 1
    Last Post: 03-12-2009, 09:55 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