I have an Access DB that I'm attempting, for display purposes, to add an unbound text field to a continuous subform that contains a row number for each record. From a really old previous post I can make it work when I open the subform by itself, but it does not work when I open the main form with the subform attached.
The public module code is written:
The text field, in the subform, is titled "RowNum" and I have the following as the control source:
I've tried so many different ways and either get #Name or #Error.
Please help!
The public module code is written:
Code:
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum
'Purpose: Numbering the rows on a form.
'Usage: Text box with ControlSource of: =RowNum([Forms]![myForm])
With frm.RecordsetClone
.Bookmark = frm.Bookmark
RowNum = .AbsolutePosition + 1
End With
Exit_RowNum:
Exit Function
Err_RowNum:
If Err.Number <> 3021& Then 'Ignore "No bookmark" at new row.
Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
End If
RowNum = Null
Resume Exit_RowNum
End Function
=RowNum([Forms]![frmMainForm]![Child3].Form)
I've tried so many different ways and either get #Name or #Error.
Please help!
Comment