Line Numbers On Subform

  • Thread starter Thread starter Jeff G
  • Start date Start date
J

Jeff G

All -

I have a form with a subform. What I'd like to be able to do is to put line
numbers on the subform, so that the user can tell how manly line number are
on the subform.

Any ideas on how I can accomplish this?

Thanks in advance.

Jeff
 
Add a field named Line to your subform's underlying table, then in the
subform's Current event use:

Private Sub Form_Current()

Dim x As Integer

x = DMax("Line", "TableName", "ID =" & Me.Parent.txtID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

Where ID is the Primary Key in the Main table and txtID is the textbox
holding it. And txtLine is the textbox in the sunform.
 
I don't want to assign line numbers to the record.

All I want to do is show the line item number in the underlying query.

Example:

Record 123
subform has 5 records - I'd like to show each line item, numbered 1-5

Record 456
subform has 10 records - I'd like to show each line item, numbered 1-10

Nothing needs to be written to the table...it's only to show line numbers.

Thanks.

Jeff
 
Back
Top