Solved

Subform Running Sum

Posted on 1998-11-04
5
250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

14 Experts available now in Live!

Get 1:1 Help Now