ActiveDatasheet 屬性

此頁沒有內容條目
內容

expandtri全部顯示

使用 ActiveDatasheet 屬性可以和 Screen 對象一起來標識或引用獲得焦點數(shù)據(jù)表Form 對象,只讀。

expression.ActiveDatasheet

expression     必需。返回“應用于”列表中的一個對象的表達式。

設置

ActiveDatasheet 屬性設置包含了在運行時獲得焦點的數(shù)據(jù)表對象。

此屬性僅在使用Visual Basic 時才可用,并且在所有視圖中具有只讀屬性。

說明

您可以使用該屬性來引用活動數(shù)據(jù)表及其一個屬性或方法。例如,下面的代碼使用 ActiveDatasheet 屬性引用活動數(shù)據(jù)表中選定區(qū)域的第一行。

TopRow = Screen.ActiveDatasheet.SelTop

示例

下面的示例使用 ActiveDatasheet 屬性標識獲得焦點的數(shù)據(jù)表單元格,如果同時選定多個單元格,則定位于選定區(qū)域中的第一行第一列。

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