Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

Record counter for navigation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 25 Nov 2007 01:59 GMT
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
Allen Browne - 25 Nov 2007 02:22 GMT
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

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>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.
Linq Adams - 25 Nov 2007 04:02 GMT
Or to show "Record X of Y Records"

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

>Try a text box with Control Source of:
>    =[Form].[CurrentRecord]
[quoted text clipped - 9 lines]
>> I'm doing this to have more control over the appearance of the buttons and
>> counter.

Signature

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

Answers/posts based on Access 2000/2003

Robert - 25 Nov 2007 17:23 GMT
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.

> Or to show "Record X of Y Records"
>
[quoted text clipped - 17 lines]
>>> and
>>> counter.
Linq Adams - 25 Nov 2007 20:34 GMT
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

Signature

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

Answers/posts based on Access 2000/2003

Dirk Goldgar - 25 Nov 2007 20:41 GMT
> 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
[quoted text clipped - 5 lines]
> 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

?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Robert - 25 Nov 2007 21:28 GMT
I'm using a subform for this.  Where would I put this code?

>> I've never had this problem with this code, but I have heard of others
>> who
[quoted text clipped - 15 lines]
>
> ?
Dirk Goldgar - 27 Nov 2007 02:13 GMT
> 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?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Robert - 25 Nov 2007 21:24 GMT
It is actually a subform.  Maybe that has something to do with it.

> 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
[quoted text clipped - 5 lines]
> DoCmd.GoToRecord , , acFirst
> End Sub
Robert - 25 Nov 2007 21:32 GMT
Clicking Last and then First on either form does not work.  Clicking Next
twice and then Previous twice always seems to work.

> 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
[quoted text clipped - 5 lines]
> DoCmd.GoToRecord , , acFirst
> End Sub
David W. Fenton - 26 Nov 2007 00:12 GMT
> 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.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Robert - 26 Nov 2007 01:52 GMT
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
[quoted text clipped - 27 lines]
> efficient to check one property that can always be counted on to
> behave consistently rather than checking two.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.