ActiveDatasheet Property

Applies To

Screen Object.

Description

You can use the ActiveDatasheet property together with the Screen object to identify or refer to the Datasheet that has the focus.

Setting

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

This property is available only in Visual Basic and is read-only in all views.

Remarks

You can use the ActiveDatasheet 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

See Also

ActiveControl Property; ActiveForm Property; ActiveReport Property; Screen Object; SelHeight, SelWidth Properties; SelTop, SelLeft Properties.

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.


Sub GetSelection()
    Dim obj As Object
    Dim lngFirstRow As Long, lngFirstColumn As Long
    Const conNoActiveDatasheet = 2484
    On Error GoTo GetSelection_Err
    Set obj = Screen.ActiveDatasheet
    lngFirstRow = obj.SelTop
    lngFirstColumn = obj.SelLeft
    MsgBox "The first item in this selection is located at " _
        & "Row " & lngFirstRow & ", Column " & lngFirstColumn_Bye:
    Exit Sub_Err:
    If Err = conNoActiveDatasheet Then
        Resume GetSelection_Bye
    End IfSub