Solved

How to sequentally number records displayed on a subform

Posted on 2003-12-04
2
379 Views
Last Modified: 2012-05-04
I have a subform which displays a selection, based on a query, of records from a main table. Is there an easy way to add a text box with a sequential number for each record.
The form displays using a Continuous Forms format.
0
Comment
Question by:NPOS
2 Comments
 
LVL 3

Accepted Solution

by:
Drizzt95 earned 100 total points
ID: 9880596
There may be an easier way but this works:

Add a module and paste the following in:

Public intCounter As Integer

Public Function Counter() As Integer
    intCounter = intCounter + 1
    Counter = intCounter
End Function

Add a text box and change the control source to:
=Counter()

You need to add intCounter = 0 to somewhere where the subform data is changed.  This may be in the main form or something, but I think it would also work in the subform under Form_DataSetChange() or Form_DataChange().  I'm not a hundred percent sure on that part.

I don't know what your knowledge is of VBA, so let me know if this is beyond you and I'll try to explain it better.
0
 

Author Comment

by:NPOS
ID: 9881005
Thanks Dizzt95

That worked perfectly. Took a little experimaentatin to work out where to put the intCounter = 0  - but I managed it, even though I am certainly no VBA expert. m learning gradually though.

In this case I put it in the main form, where I have requery statements that run the subforms including the one I needed this for.

Many thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
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…

820 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