Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to sequentally number records displayed on a subform

Posted on 2003-12-04
2
Medium Priority
?
405 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 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

927 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