Record Counters Caption

RXX00

Registered User.
Local time
Today, 18:39
Joined
May 24, 2011
Messages
26
Hi,

I have a form and I have turned the record selectors off.

Due to this I have created 2 buttons that allow the user to go back and forward though the records. This is working fine.

I have now put in a caption that says "Record 1 of 35" using "me.caption =" code. I put this in the on current event of the form.

My problem is that when the form opens the caption reads "Record 1 of 1" until I move to another record and then it starts to work.

So when it opens it says "Record 1 of 1", then I click the "NEXT" button and it reads "Record 2 of 35" and when I click the "BACK" button it then reads "Record 1 of 35".

Is there any way I can get this caption to be correct when the form load to start with?

Thanks in Advance.
 
Depending on what your code is, you may just need to add a line to move through the recordset to get an accurate record count. Example;

Code:
With Me.RecordsetClone
    .MoveLast
    Me!YourLabel.Caption = "Record " & Me.CurrentRecord & " of " & .RecordCount
End With
 
Depending on what your code is, you may just need to add a line to move through the recordset to get an accurate record count. Example;

Code:
With Me.RecordsetClone
    .MoveLast
    Me!YourLabel.Caption = "Record " & Me.CurrentRecord & " of " & .RecordCount
End With

The problem is that I need it to open on the 1st record, I guess I could move forward 1 record then back again - would that work?
 
The code I posted uses the RecordsetClone property, not the actual Recordset, so the .MoveLast has no effect on the position of the record pointer in the actual set of records that you see in your form. It just moves through a cloned copy of the Recordset to determine the total number of records. In other words, your form will still open to the first record, unless you have some other code that would affect this behavior.
 

Users who are viewing this thread

Back
Top Bottom