Record counter for navigation


R

Robert

I have eliminated the navigation buttons on my form and replaced them with
command buttons. Now how do I make a textbox show a record count just like
the standard record counter? This counter would not be bound to any field
in the table, but would just be a count starting with 1 of whatever records
comprise the current query.

I'm doing this to have more control over the appearance of the buttons and
counter.

Robert
 
Ad

Advertisements

L

Linq Adams via AccessMonster.com

Or to show "Record X of Y Records"

="Record " & [CurrentRecord] & " Of " & RecordsetClone.RecordCount & "
Records"

Allen said:
Try a text box with Control Source of:
=[Form].[CurrentRecord]

More info in:
Numbering Entries in a Report or Form
at:
http://allenbrowne.com/casu-10.html
I have eliminated the navigation buttons on my form and replaced them with
command buttons. Now how do I make a textbox show a record count just like
[quoted text clipped - 4 lines]
I'm doing this to have more control over the appearance of the buttons and
counter.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
R

Robert

Thank you. When I do this it says "Record 1 of 1" on the first record when
there are 6 existing records. If I move forward one it says "Record 2 of 6"
(okay). If I go back one from there it says "Record 1 of 1" (not okay). If
I move forward two and then back two it says "Record 1 of 6" (okay). It
always says "Record 1 of 1" (not okay) when I first display the form.

Linq Adams via AccessMonster.com said:
Or to show "Record X of Y Records"

="Record " & [CurrentRecord] & " Of " & RecordsetClone.RecordCount & "
Records"

Allen said:
Try a text box with Control Source of:
=[Form].[CurrentRecord]

More info in:
Numbering Entries in a Report or Form
at:
http://allenbrowne.com/casu-10.html
I have eliminated the navigation buttons on my form and replaced them
with
command buttons. Now how do I make a textbox show a record count just
like
[quoted text clipped - 4 lines]
I'm doing this to have more control over the appearance of the buttons
and
counter.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
L

Linq Adams via AccessMonster.com

I've never had this problem with this code, but I have heard of others who
have! The usual answer is to move to the lasrt record then back to the first
record.

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acFirst
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
D

Dirk Goldgar

Linq Adams via AccessMonster.com said:
I've never had this problem with this code, but I have heard of others who
have! The usual answer is to move to the lasrt record then back to the
first
record.

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acFirst
End Sub


Does it work to do this in the RecordsetClone, which might be less
noticeable:

With Me.RecordsetClone
If Not .EOF Then .MoveLast
End With

?
 
Ad

Advertisements

R

Robert

Clicking Last and then First on either form does not work. Clicking Next
twice and then Previous twice always seems to work.
 
D

David W. Fenton

When I do this it says "Record 1 of 1" on the first record when
there are 6 existing records. If I move forward one it says
"Record 2 of 6" (okay). If I go back one from there it says
"Record 1 of 1" (not okay). If I move forward two and then back
two it says "Record 1 of 6" (okay). It always says "Record 1 of
1" (not okay) when I first display the form.

DAO recordsets use Rushmore technology to populate themselves. What
this means is that the first few records of the recordset become
available before the end of the recordset has been fully loaded. I'm
sure you've seen this in many instances.

The .RecordsetCount property of a recordset is not accurate until
the recordset has been fully loaded. To force this to happen, you
have to .MoveLast. So, in your subform's LOAD event:

Me.RecordsetClone.MoveLast
Me.RecordsetClone.MoveFirst

Now Me.RecordsetClone.RecordCount will be accurate.

The other thing to remember is that .Recordset will be 0 if no
records are returned and 1 or more if there are records returned.
So, if you want to know if a recordset has records in it, you need
only check if the RecordCount is 0 or not. You need to .MoveLast
only when you need the exact count.

When I'm checking if a recordset has records, I just test
..RecordCount = 0, rather than .EOF And .BOF. I think it's more
efficient to check one property that can always be counted on to
behave consistently rather than checking two.
 
R

Robert

Thank you.
David W. Fenton said:
DAO recordsets use Rushmore technology to populate themselves. What
this means is that the first few records of the recordset become
available before the end of the recordset has been fully loaded. I'm
sure you've seen this in many instances.

The .RecordsetCount property of a recordset is not accurate until
the recordset has been fully loaded. To force this to happen, you
have to .MoveLast. So, in your subform's LOAD event:

Me.RecordsetClone.MoveLast
Me.RecordsetClone.MoveFirst

Now Me.RecordsetClone.RecordCount will be accurate.

The other thing to remember is that .Recordset will be 0 if no
records are returned and 1 or more if there are records returned.
So, if you want to know if a recordset has records in it, you need
only check if the RecordCount is 0 or not. You need to .MoveLast
only when you need the exact count.

When I'm checking if a recordset has records, I just test
.RecordCount = 0, rather than .EOF And .BOF. I think it's more
efficient to check one property that can always be counted on to
behave consistently rather than checking two.
 
Ad

Advertisements

D

Dirk Goldgar

Robert said:
I'm using a subform for this. Where would I put this code?


Is the subform related to the current record on the main form, so that it
has a different set of records to display depending on which record is
displayed on the main form?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top