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 by using a macro or Visual Basic and is read-only in all views.
Remarks
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
See Also
ActiveControl property, ActiveForm property, ActiveReport property, 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 objDatasheet As Object
Dim lngFirstRow As Long, 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
GetSelection_Bye:
Exit Sub
GetSelection_Err:
If Err = conNoActiveDatasheet Then
Resume GetSelection_Bye
End If
End Sub