Solved

Subform Running Sum

Posted on 1998-11-04
5
249 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
Comment Utility
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
Comment Utility
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
Comment Utility
i dont know which question brewdog was trying to answer
but bclarck's comment did the trick
0
 
LVL 3

Expert Comment

by:tcurtin
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now