Solved

Line Number in a form

Posted on 2002-06-28
6
251 Views
Last Modified: 2006-11-17
Hi everyone, I am working on an Access 2000 training database.  In the main form I have an employee and in the subform I have a list of training needed.  I want to number the rows returned in the subform:
   1) class
   2) class
   3) class. etc.

How do I put the numbers and ")" in the form?  Thanks for your help.

Gladys

0
Comment
Question by:gkadell
6 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 7117152
In case your Training table has an autonumber, just add in the query editor a field like:

SeqNo:DCOUNT("[TrainingID]","tblTraining","EmployeeID="&[EmployeeID]&" AND TrainingID<="&[TrainingID]) & ") "

This will count the number of autonumberID's less or equal the current, thus numbering from 1 to ... and the ") " will add the needed trailing ")"

Just make sure the tablename and fieldnames are filled in correctly.

Nic;o)
0
 

Author Comment

by:gkadell
ID: 7118988
Thanks - I haven't had a chance to try it, but I will tomorrow.
0
 
LVL 2

Accepted Solution

by:
DSS earned 200 total points
ID: 7119070
This will work too...

1.  Put this code in a module:

Global NextSeqVar As Long

Function NextSeq() As String
    NextSeq = NextSeqVar + 1 & ")"
    NextSeqVar = NextSeqVar + 1
   
End Function

2. Put this line of code in the onLoad event of the form you are designing:

NextSeqVar = 0

3. Put this as the Control Source of the field that will display the record number:

=NextSeq()



0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:gkadell
ID: 7121901
Thanks, I'll get back to you guys soon...
0
 
LVL 57
ID: 7133583
And as a 3rd alternative, you can add a field to the underlying recordsource (table) to hold the "row display" value.

You may want to do this as the last solution posted will change the row numbers if the user is able to scroll in the subform.  

Nico's solution avoids this, but the DCount() will be slow if the recordset is large.

If you go this route, you can use the last solution posted as part of an update query to update the field, then display the subform.  That should be fast and efficent and avoid the scrolling problem.

Jim.
0
 

Author Comment

by:gkadell
ID: 7178469
Thank you all very much for your input.  It took me a little while to test all of your options, and I sincerely apologize for the delay.  Nico, the only reason your answer didn't work was because one of my fields was a text field and the others were integers - and I received mismatched field errors.  DSS your answer worked great.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

932 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

8 Experts available now in Live!

Get 1:1 Help Now