Hi
Please would anyone help that I need to add a text box to show the record number automatically once a record is added or delete. It is a form for agenda items, so once someone add text into a field then the text box will show 1 for item 1, and 2 for item 2 and if record is deleted then the number will be in sequence automatically.
I have tried to add Event Procedure below but it only shows the last record's number to each text box:
(Text box name txtPosition)
Private Sub Form_Current()
On Error GoTo Err_Form_Current
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
Me.txtPosition = rst.AbsolutePosition + 1
Exit_Form_Current:
Set rst = Nothing
Exit Sub
Err_Form_Current:
If Err = 3021 Then 'No current record
Me.txtPosition = rst.RecordCount + 1
Else
MsgBox Error$, 16, "Error in Form_Current()"
End If
Resume Exit_Form_Current
End Sub
Please could anyone help?
Many thanks!
Please would anyone help that I need to add a text box to show the record number automatically once a record is added or delete. It is a form for agenda items, so once someone add text into a field then the text box will show 1 for item 1, and 2 for item 2 and if record is deleted then the number will be in sequence automatically.
I have tried to add Event Procedure below but it only shows the last record's number to each text box:
(Text box name txtPosition)
Private Sub Form_Current()
On Error GoTo Err_Form_Current
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
Me.txtPosition = rst.AbsolutePosition + 1
Exit_Form_Current:
Set rst = Nothing
Exit Sub
Err_Form_Current:
If Err = 3021 Then 'No current record
Me.txtPosition = rst.RecordCount + 1
Else
MsgBox Error$, 16, "Error in Form_Current()"
End If
Resume Exit_Form_Current
End Sub
Please could anyone help?
Many thanks!