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():
- Open the sample database Northwind.mdb.
- Open the Employees (page break) form in Design view.
- Set the EmployeeID control's OnDblClick property to =WhichPage(Form,[EmployeeID]).
- For the EmployeeID control, set the Enabled property to Yes and the Locked property to No.
- Set the Address control's OnDblClick property to =WhichPage(Form,[Address]). Save and then close the form.
- Create a module and type the following lines in the Declarations section if they are not already there:
Option Compare Database
Option Explicit
- 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
- Close the module and save it as Module Test.
- 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.