ActiveDatasheet Property [Access 2003 VBA Language Reference]
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.
expression.ActiveDatasheet
expression Required. An expression that returns one of the objects in the Applies To list.
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
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
Applies to | Screen Object
See Also | ActiveControl Property | ActiveForm Property | ActiveReport Property | SelHeight Property | SelTop Property