capturing the record number and total records in a form with no navigation buttons

  • Thread starter Thread starter Paul James
  • Start date Start date
P

Paul James

When you set the Navigation Buttons property of a form to No, how do you
capture

1. the total number of records in the form's underlying recordset, and
2. the record number of the current record?

so you can display them in an unbound control on the form?

Thanks in advance.

Paul
 
I get an error with .CurrentRecord (object doesn't support this property or
method). Am I missing something?

If Not Me.NewRecord Then
With Me.RecordsetClone
.Bookmark = Me.Bookmark
intRecNum = .CurrentRecord
intRecCount = .RecordCount
End With
Else
With Me.RecordsetClone
.MoveLast
intRecNum = .CurrentRecord + 1
intRecCount = .RecordCount + 1
End With
End If

txtRecNum.Value = intRecNum
txtRecCount.Value = "of " & intRecCount

Thanks,
Max
 
I used the code at http://www.lebans.com/recnavbuttons.htm and it worked
beautifully! The txtPos_AfterUpdate() routine fails when the user enters an
out of range number (I could fix it but I never use that feature anyway), so
I just commented out the routine.

My existing code did the same thing, but the subform makes it much easier to
reuse. The only thing I added was to run my validation routines in the
SFfrmNavButtons_Enter() event.

Thanks!
Max

Max Smart said:
I get an error with .CurrentRecord (object doesn't support this property or
method). Am I missing something?

If Not Me.NewRecord Then
With Me.RecordsetClone
.Bookmark = Me.Bookmark
intRecNum = .CurrentRecord
intRecCount = .RecordCount
End With
Else
With Me.RecordsetClone
.MoveLast
intRecNum = .CurrentRecord + 1
intRecCount = .RecordCount + 1
End With
End If

txtRecNum.Value = intRecNum
txtRecCount.Value = "of " & intRecCount

Thanks,
Max
 
Max said:
I get an error with .CurrentRecord (object doesn't support this property or
method). Am I missing something?

If Not Me.NewRecord Then
With Me.RecordsetClone
.Bookmark = Me.Bookmark
intRecNum = .CurrentRecord
intRecCount = .RecordCount
End With
Else
With Me.RecordsetClone
.MoveLast
intRecNum = .CurrentRecord + 1
intRecCount = .RecordCount + 1
End With
End If

txtRecNum.Value = intRecNum
txtRecCount.Value = "of " & intRecCount


CurrentRecord is a property of the Form object, not the
Recordset object. That shoud be:
Me.CurrentRecord
 
CurrentRecord is a property of the Form object, not the
Recordset object. That shoud be:
Me.CurrentRecord

True. Here's what I'm using in my form to create the label:

Me!lblNavigate.Caption = "Record " & Me.CurrentRecord & " of " &
Me.Recordset.RecordCount
 
Back
Top