ACC2000: Sample Function to Determine Current Page of a Form

ID: Q210336


The information in this article applies to:
  • Microsoft Access 2000

Moderate: Requires basic macro, coding, and interoperability skills.


SUMMARY

This article shows you how to create a sample, user-defined function that you can use on a multiple-page form that contains page breaks to determine which page of the form is current.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The following steps demonstrate how to create and use the sample function WhichPage():
  1. Open the sample database Northwind.mdb.


  2. Open the Employees (page break) form in Design view.


  3. Set the EmployeeID control's OnDblClick property to =WhichPage(Form,[EmployeeID]).


  4. For the EmployeeID control, set the Enabled property to Yes and the Locked property to No.


  5. Set the Address control's OnDblClick property to =WhichPage(Form,[Address]). Save and then close the form.


  6. Create a module and type the following lines in the Declarations section if they are not already there:


  7. 
    Option Compare Database
    Option Explicit 
  8. Type the following procedure:


  9. 
    Function WhichPage (F As Form, MyControl As Control)
       Dim Page, I As Integer
       Dim C As Control
       Page = 1
    
       For I = 1 To F.Count - 1
          Set C = F(I)
          If TypeOf C Is PageBreak Then
             If C.Top < MyControl.Top Then Page = Page + 1
          End If
       Next I
    
       MsgBox "Page= " & Page
    End Function 
  10. Close the module and save it as Module Test.


  11. Open the Employees (page break) form in Form view. Double-click the EmployeeID field, and then the Address field. Note that the function displays the number of the page containing the control.


Additional query words: inf

Keywords : kbdta AccCon FmsHowto KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.