Line numbers on forms

Brian Martin

Registered User.
Local time
Today, 22:53
Joined
Jul 24, 2002
Messages
68
I want to display a list of records on a form and I want a number to be displayed alongside each record from 1 - number of records. I don't want to store these numbers in tables though I just want them to appear on the form. I thought about doing something involving the count function and creating a procedure with a for loop that creates textboxes from 1 to count but I'm not too sure how to go about this. Anyone got any ideas??:)
 
I see what ur saying there Rich but I still can't get my head rounf how to use it. I've got a text box called line number that I want to list the numbers in. Doesn'y current record only refer to the currently selected record. How can I get it to list numbers 1- Number of records alongside each record?
 
Use this function
Function GetLineNumber(F As Form, KeyName As String, KeyValue)
Dim RS As Recordset
Dim CountLines

On Error GoTo Err_GetLineNumber

Set RS = F.RecordsetClone

' Find the current record.
Select Case RS.Fields(KeyName).Type
' Find using numeric data type key value?
Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
DB_DOUBLE, DB_BYTE
RS.FindFirst "[" & KeyName & "] = " & KeyValue
' Find using date data type key value?
Case DB_DATE
RS.FindFirst "[" & KeyName & "] = #" & KeyValue & "#"
' Find using text data type key value?
Case DB_TEXT
RS.FindFirst "[" & KeyName & "] = '" & KeyValue & "'"
Case Else
MsgBox "ERROR: Invalid key field data type!"
Exit Function
End Select

' Loop backward, counting the lines.
Do Until RS.BOF
CountLines = CountLines + 1
RS.MovePrevious
Loop

Bye_GetLineNumber:
' Return the result.
GetLineNumber = CountLines

Exit Function

Err_GetLineNumber:
CountLines = 0
Resume Bye_GetLineNumber

End Function
 

Users who are viewing this thread

Back
Top Bottom