ACC: How to Display the Page Number on a Multiple Page Form

Last reviewed: April 2, 1997
Article ID: Q132144
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

Forms that contain more content than can fit on one screen can use page breaks to enable you to use the PAGE UP and PAGE DOWN keys to display the content on different screens. The Employees form in the sample database NWIND.MDB uses this PAGE UP and PAGE DOWN key feature. This article shows you how you can add a text box to the Employees form that, through the use of a macro, displays the current page number when you press the PAGE UP or PAGE DOWN keys.

MORE INFORMATION

To add the page number feature to the Employees form, follow these steps.

CAUTION: Following the steps in this example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.

  1. Create the following macro and save it as EmpFormPageNums:

          Macro Name   Action
          --------------------
          Page1        SetValue
    
          Page2        SetValue
    
          Page1 Actions
          -----------------------------------------
          SetValue
             Item: [Forms]![Employees]![txtpageNum]
             Expression: "Page #1 of 2"
    
          Page2 Actions
          -----------------------------------------
          SetValue
             Item: [Forms]![Employees]![txtpageNum]
             Expression: "Page #2 of 2"
    
    

  2. Open the Employees form in Design view, and set the form footer section's Visible property to Yes.

  3. Add a text box control to the form footer section, and set the control's Name property as follows:

          txtPageNum
    

  4. Set the Employee ID control's OnEnter property as follows:

          EmpFormPageNums.Page1
    

  5. Set the Address control's OnEnter property as follows:

          EmpFormPageNums.Page2
    

  6. Close and save the form.

  7. Open the Employees form in Form view. Note that when you use the PAGE UP and PAGE DOWN keys to view the form, the text box in the form footer section displays the current page you are on by using the Enter event for the first control on each page. This technique works on the first control on each page that has the lowest tab order.

REFERENCES

Microsoft Access "User's Guide," version 2.0, Chapter 24, "Macro Basics"

Microsoft Access "User's Guide," version 2.0, Chapter 25, "Using Macros with Forms"


Keywords : FmsHowto kbusage
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.