Solved

Subform Running Sum

Posted on 1998-11-04
5
253 Views
Last Modified: 2008-02-26
I have a main form with a linked subform.
the subform is set for continueous forms. i would like to be able to number each record on the subform, just like the runningsum feature in reports. how?
0
Comment
Question by:rolo
5 Comments
 
LVL 10

Expert Comment

by:brewdog
ID: 1967627
Can you just set up an AutoNumber field in the table the subform is based on? Even if you don't use the numbers, that's the easiest way to track the count of records.

brewdog
0
 
LVL 2

Expert Comment

by:bclark100898
ID: 1967628
Add a textbox to the subform.

set the control source of the text box
=RecNum()

Create a function in the subform called RecNum
Also, do a recalc when records are added or deleted from the subform.


This code is added to the subform.

Public Function RecNum()

    On Error GoTo NoCurrentRecord
   
    'this line fails if a new record is being inserted
    Me.RecordsetClone.Bookmark = Me.Bookmark

    RecNum = Me.RecordsetClone.AbsolutePosition + 1
   
    Exit Function

NoCurrentRecord:

End Function

Private Sub Form_AfterDelConfirm(Status As Integer)
    Me.Recalc
End Sub

Private Sub Form_AfterInsert()
    Me.Recalc
End Sub



0
 

Author Comment

by:rolo
ID: 1967629
i dont know which question brewdog was trying to answer
but bclarck's comment did the trick
0
 
LVL 3

Expert Comment

by:tcurtin
ID: 1967630
The autonumber may not be a valid representation of the number of records especially if a record is deleted or 'escaped' while being entered. If a new record is escaped and then reentered, Access's Autonumber WILL increment.
0
 
LVL 2

Accepted Solution

by:
bclark100898 earned 20 total points
ID: 1967631
I looks like I posted a Comment document earlier, not an Answer.  So, here is an Answer document.

Also, on a subform, one could get most any subset of records, in most any order.  An autoincrement indicates the order in which records are added, it does not indicate the order in which they are displayed.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question