Page numbers in forms (Access 2010)

Jram

New member
Local time
Today, 12:43
Joined
Feb 21, 2012
Messages
3
Hi,

I am new to access, so this may be a problem that is very simple to solve.

I have a form that contains a sub form. Depending of the selection from the combo box on the main form a number of records are returned in the sub form. I can see how many from the navigation bar at the button of the form.

Is there a way of displaying the "1 of 5" visible in the sub form bottom navigation bar in a text box? There is a page number button for reports in the ribbon but this is not available for forms.

I have tried adding a text box with ="Page " & [Page] & " of " & [Pages] as the control source but get a #Type error.

Any help appreciated.
 
You can create your own record counter using the following code pasted into the On Current Event of your form, you will also need to add an unbound text box to your form to display the results;
Code:
[COLOR="SeaGreen"]' Provide a record counter for using with
' custom navigation buttons (when not using
' Access built in navigation)
[/COLOR]
    Dim rst As DAO.Recordset
    Dim lngCount As Long

    Set rst = Me.RecordsetClone

    With rst
        .MoveFirst
        .MoveLast
        lngCount = .RecordCount
    End With
    
[COLOR="SeaGreen"]'Show the result of the record count in the text box (YourTextBoxName)[/COLOR]

    Me.YourTextBoxName= "Record " & Me.CurrentRecord & " of " & lngCount
 
That's brilliant John, worked a treat!

Thanks
 

Users who are viewing this thread

Back
Top Bottom