Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numbering Records from a query

Status
Not open for further replies.

Corina

Programmer
Jun 20, 2001
4
NZ
I have a (continuous) form that access a query.
I want to display the record number of each record next to it.
eg.
My results from the query are:
Commissions
Adjustment
Overrides
Credit Cards

I want this displayed on a form like:
1. Commissions
2. Adjustment
3. Overrides
4. Credit Cards.

Any ideas?

B

[amidala]
 
Hi,
You can try working with the AbsolutePosition (its a property of the Recordset) Mal'chik [bigglasses]
 
I just finished this same thing about 10 minutes ago...

For each list of items in my subform, I number the rows from 1 to ???. When the main record changes, the associated rows in the subform are again numbered from 1 to ???.


I created a module, Module1, and defined my record counter as follows:

Public RecCounter As Integer 'record counter on forms


Also in Module1, I put this public function:

Private Function CountRecord()

RecCounter = RecCounter + 1
CountRecord = RecCounter

End Function



In my main form, I set the counter to zero in the Form_Current event (which occurs each time the focus moves to a record) so that it can resets my record count on the subform:

Private Sub Form_Current()

RecCounter = 0

End Sub



On my subform, which is defined as a continuous form, I created a text box in the detail section next to my other fields and defined the CONTROL SOURCE as follows:

=CStr(CountRecord()) & "."


As long as I didn't forget to document a step here, it should work just fine.

Nittany92
 
If you don't have a main form as I listed in my example above, you can probably put the line "RecCounter = 0" in the Form_Load() event of your continuous form.

I believe the rest remains the same.

Give it a try.
Nittany92
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top