GoToPage Method

Microsoft Access Visual Basic

Show All

GoToPage Method

       

GoToPage method as it applies to the Form object.

The GoToPage method moves the focus to the first control on a specified page in the active form.

expression.GoToPage(PageNumber, Right, Down)

expression   Required. An expression that returns one of the above objects.

PageNumber  Required Long. A numeric expression that's a valid page number for the active form.

Right  Optional Long. A numeric expression that's a valid horizontal offset (in twips) from the left side of the window to the part of the page to be viewed.

Down  Optional Long. A numeric expression that's a valid vertical offset (in twips) from the top of the window to the part of the page to be viewed.

GoToPage method as it applies to the DoCmd object.

The GoToPage method of the DoCmd object carries out the GoToPage action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

expression.GoToPage(PageNumber, Right, Down)

expression   Required. An expression that returns one of the above objects.

PageNumber  Required Variant. A numeric expression that's a valid page number for the active form. If you leave this argument blank, the focus stays on the current page. You can use the right and down arguments to display the part of the page you want to see.

Right  Optional Variant. A numeric expression that's a valid horizontal offset for the page.

Down  Optional Variant. A numeric expression that's a valid vertical offset for the page.

Remarks

Remarks as it applies to the Form object.

When you use this method to move to a specified page of a form, the focus is set to the first control on the page, as defined by the form's tab order. To move to a particular control on the form, use the SetFocus method.

You can use the GoToPage method if you've created page breaks on a form to group related information. For example, you might have an Employees form with personal information on the first page, office information on the second page, and sales information on the third page. You can use the GoToPage method to move to the desired page.

You can use the right and down arguments for forms with pages larger than the Microsoft Access window. Use the pagenumber argument to move to the desired page, and then use the right and down arguments to display the part of the page you want to see. Microsoft Access displays the part of the page that's offset from the upper-left corner of the window by the distance specified in the right and down arguments.

Remarks as it applies to the DoCmd object.

The units for the right and down arguments are expressed in twips.

If you specify the right and down arguments and leave the pagenumber argument blank, you must include the pagenumber argument's comma. If you don't specify the right and down arguments, don't use a comma following the pagenumber argument.

The GoToPage method of the DoCmd object was added to provide backwards compatibility for running the GoToPage action in Visual Basic code in Microsoft Access 95. It's recommended that you use the existing GoToPage method of the Form object instead.

Example

Exmaple as it applies to the Form object.

The following example uses the GoToPage method to move the focus to the second page of the Customer form at the position specified by the right and down arguments:

Forms!Customer.GoToPage 2, 1440, 600

Example as it applies to the DoCmd object.

The following example uses the GoToPage method to move the focus to the position specified by the horizontal and vertical offsets on the second page of the active form:

DoCmd.GoToPage 2, 1440, 567