We help IT Professionals succeed at work.

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

MissB618
MissB618 asked
on
507 Views
Last Modified: 2008-01-09
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.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
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
CERTIFIED EXPERT
Top Expert 2016

Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
MissB618,

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

mx
Eric ShermanAccountant/Developer
CERTIFIED EXPERT

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

https://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_22856605.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

Author

Commented:
ET,
Where would I put this code?
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
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
Eric ShermanAccountant/Developer
CERTIFIED EXPERT

Commented:
MissB618 ...

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

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


ET
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.