Link to home
Start Free TrialLog in
Avatar of MissB618
MissB618Flag for United States of America

asked on

How can I add a custom record counter/navigation bar to my subform?

I have a subform within my main form.  I need to add a custom navigation bar to the subform.  I know how to add the "next record", "new record" and "previous record" buttons to my custom bar.  What I do not know how to do is the "1 of 5" part of the record navigation bar.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add a text box on your subform and set the Control Source to the following expression:

=[Form].[CurrentRecord] & " of " & [Form].[RecordsetClone].[RecordCount]

Don't forget the equals sign.

mx
you may need to add this codes too in the current event of the subform

Private Sub Form_Current()
Set rs = Me.RecordsetClone
rs.MoveLast
    Me.txtRecCount = Me.CurrentRecord & " of " & rs.RecordCount


end sub
MissB618,

The one line I posted will always show you the Record N of Total no matter what record you are on.

mx
Review this question.  The asker was trying to do exactly what you are trying to accomplish.

https://www.experts-exchange.com/questions/22856605/Refresh-rs-RecordCount.html

This is the solution I provided.  This will increment properly when you go to the new record.


If Me.Form.RecordsetClone.RecordCount > 0 Then
    'Shows current record count
     Set rs = Me.RecordsetClone
     rs.MoveLast
     If Me.NewRecord Then
            Me.txtRecCount = Me.CurrentRecord & " of " & rs.RecordCount + (Me.CurrentRecord - rs.RecordCount) & " record(s)."
     Else
            Me.txtRecCount = Me.CurrentRecord & " of " & rs.RecordCount & " record(s)."
    End If
    Else
        'Do nothing
    End If

ET
Avatar of MissB618

ASKER

ET,
Where would I put this code?
B618 ....

If you need to emulate the nav rec counter/display ... the put this as the Control Source for a text box the will display this information:

=[Form].[CurrentRecord] & " of " & [Form].[RecordsetClone].[RecordCount]

mx
MissB618 ...

>>>>ET,
Where would I put this code?<<<<<

Put the code in the On Current Event of your form.


ET