Item numbers?

  • Thread starter Thread starter Steve Warren
  • Start date Start date
S

Steve Warren

Error 3021 Because of a null field. It works fine until I scroll down a
list and get to a null field. It also looks like itheir is coding for it,
when i hit debug it stops at .Bookmark = frm.Bookmark

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([Form])

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
 
Check the setting of your error trapping option (in the VBA editor, from the
Tools menu, select Options, and in the Options dialog box, select the
General tab). You want it set to 'Break on unhandled errors' when testing
this code.

--
Brendan Reynolds


Steve Warren said:
Error 3021 Because of a null field. It works fine until I scroll down a
list and get to a null field. It also looks like itheir is coding for
it,
when i hit debug it stops at .Bookmark = frm.Bookmark

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([Form])

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


Douglas J. Steele said:
Works fine for me using Access 2003.

What error are you getting?
 
Dat be it!.........Thank You
Brendan Reynolds said:
Check the setting of your error trapping option (in the VBA editor, from
the Tools menu, select Options, and in the Options dialog box, select the
General tab). You want it set to 'Break on unhandled errors' when testing
this code.

--
Brendan Reynolds


Steve Warren said:
Error 3021 Because of a null field. It works fine until I scroll down
a
list and get to a null field. It also looks like itheir is coding for
it,
when i hit debug it stops at .Bookmark = frm.Bookmark

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([Form])

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


Douglas J. Steele said:
Works fine for me using Access 2003.

What error are you getting?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Works in 97 but error problems in 2003 can you help?
message
See Stephen Lebans' RowNumber sample:

http://www.lebans.com/rownumber.htm

--
HTH
Van T. Dinh
MVP (Access)



On a report I am able to have item numbers for transactions, however
I
can not figure out how to create item numbers o
 
Back
Top