?
Solved

Subform Running Sum

Posted on 1998-11-04
5
Medium Priority
?
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 80 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

801 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