Solved

Line Number in a form

Posted on 2002-06-28
6
254 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server views 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 Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

810 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