Share via


Working with the Screen Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Other Microsoft® Office applications have properties that return a reference to active objects. For example, Microsoft® Word has the ActiveDocument property to determine which document currently has the focus. Microsoft® Excel has properties to return the active Workbook, Worksheet, Cell, Chart, and Window objects. Similarly, Microsoft® PowerPoint® has the ActivePresentation property to determine the active presentation.

In Microsoft® Access, you use the Screen object to work with the object or control that currently has the focus. The Screen object has properties that return a reference to the currently active control (on a form or report), data access page, datasheet, form, or report. These properties are useful in code that operates against an object and must know only the type of object. For example, the following line of code hides the currently active form:

Screen.ActiveForm.Visible = False

The next example shows how you can use the Screen object to determine which cell in a datasheet is selected:

MsgBox "The selected item is located at: Row " _
   & Screen.ActiveDatasheet.SelTop & ", Column " _
   & Screen.ActiveDatasheet.SelLeft

The Screen object also has properties you can use to work with the previously active control and the mouse pointer.

**Note   **If you try to refer to an object by using properties of the Screen object and there is no object of that type currently active, an error occurs.

See Also

Built-in Access Functions and Methods | Creating, Opening, and Closing an Access Application | The CurrentData and CurrentProject Objects | Working with the DoCmd Object | Working with the Modules Collection | Working with the References Collection