Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: Sample Function to Determine Current Page of a Form


View products that this article applies to.

This article was previously published under Q210336
Moderate: Requires basic macro, coding, and interoperability skills.

↑ Back to the top


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.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. 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:
    Option Compare Database
    Option Explicit
  7. Type the following procedure:
    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
  8. Close the module and save it as Module Test.
  9. 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.

↑ Back to the top


Keywords: KB210336, kbprogramming, kbhowto

↑ Back to the top

Article Info
Article ID : 210336
Revision : 4
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 374