Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources]

Alison Balter

نسخه متنی -صفحه : 544/ 139
نمايش فراداده

Special Properties That Refer to Objects

VBA offers the convenience of performing actions on the active control, the active form, and other specially recognized objects. The following is a list of special properties that refer to objects in the Access Object Model:

  • The ActiveControl property refers to the control that has focus on a screen object, form, or report.

  • The ActiveForm property refers to the form that has focus.

  • The ActiveReport property refers to the report that has focus.

  • The Form property refers to the form that a subform is contained in or to the form itself.

  • Me refers to the form or report where code is currently executing.

  • Module refers to the module of a form or report.

  • The Parent property refers to the form, report, or control that contains a control.

  • PreviousControl refers to the control that had focus immediately before the ActiveControl.

  • RecordsetClone refers to a clone of the form's underlying recordset.

  • The Report property refers to the report that a subform is contained in or to the report itself.

  • The Section property refers to the section in a form or report where a particular control is located.

The following example using the Screen.ActiveForm property shows how a subroutine can change the caption of the active form:

Sub ChangeCaption() Screen.ActiveForm.Caption = Screen.ActiveForm.Caption & _ " - " & CurrentUser() End Sub

This subroutine modifies the caption of the active form, appending the value of the CurrentUser property onto the end of the existing caption.