Share via


Screen.ActiveDatasheet Property (Access)

You can use the ActiveDatasheet property together with the Screen object to identify or refer to the datasheet that has the focus. Read-only Form object.

Syntax

expression .ActiveDatasheet

expression A variable that represents a Screen object.

Remarks

The ActiveDatasheet property setting contains the datasheet object that has the focus at run time.

You can use this property to refer to an active datasheet together with one of its properties or methods. For example, the following code uses the ActiveDatasheet property to reference the top row of the selection in the active datasheet.

TopRow = Screen.ActiveDatasheet.SelTop

Example

The following example uses the ActiveDatasheet property to identify the datasheet cell with the focus, or if more than one cell is selected, the location of the first row and column in the selection.

Public Sub GetSelection() 
 ' This procedure demonstrates how to get a pointer to the 
 ' current active datasheet. 
 
 Dim objDatasheet As Object 
 Dim lngFirstRow As Long 
 Dim lngFirstColumn As Long 
 Const conNoActiveDatasheet = 2484 
 
 On Error GoTo GetSelection_Err 
 
 Set objDatasheet = Screen.ActiveDatasheet 
 
 lngFirstRow = objDatasheet.SelTop 
 lngFirstColumn = objDatasheet.SelLeft 
 MsgBox "The first item in this selection is located at " & _ 
 "Row " & lngFirstRow & ", Column " & _ 
 lngFirstColumn, vbInformation 
 
GetSelection_Bye: 
 Exit Sub 
GetSelection_Err: 
 If Err = conNoActiveDatasheet Then 
 MsgBox "No data sheet is active.", vbExclamation 
 Resume GetSelection_Bye 
 End If 
End Sub

See Also

Concepts

Screen Object Members

Screen Object