Applies To Form, QueryDef object, Table, TableDef object.
Description
You can use the SelHeight property to specify or determine the number of selected rows (records) in the current selection rectangle in a table, query, or form datasheet, or the number of selected records in a continuous form. You can use the SelWidth property to specify or determine the number of selected columns (fields) in the current selection rectangle. For example, if you've selected a group of rows and columns within Datasheet view of the Customers table, you can use the SelHeight and SelWidth properties to determine the number of rows and columns in the selection rectangle.
Setting
These properties aren't available in Design view. These properties are only available by using a macro or Visual Basic.
See Also SelTop, SelLeft properties.
Example The following example shows how to use the SelHeight, SelWidth, SelTop, and SelLeft properties to determine the position and size of a selection rectangle in datasheet view. The SetHeightWidth procedure assigns the height and width of the current selection rectangle to the variables lngNumRows, lngNumColumns, lngTopRow, and lngLeftColumn, and displays those values in a message box.Sub SetHeightWidth(frm As Form)
Dim lngNumRows As Long, lngNumColumns As Long
Dim lngTopRow As Long, lngLeftColumn As Long
Dim strMsg As String
If frm.CurrentView = 2 Then ' Form is in Datasheet view.
lngNumRows = frm.SelHeight ' Number of rows selected.
lngNumColumns = frm.SelWidth ' Number of columns selected.
lngTopRow = frm.SelTop ' Topmost row selected.
lngLeftColumn = frm.SelLeft ' Leftmost column selected.
strMsg = "Number of rows: " & lngNumRows & vbCrLf
strMsg = strMsg & "Number of columns: " & lngNumColumns & vbCrLf
strMsg = strMsg & "Top row: " & lngTopRow & vbCrLf
strMsg = strMsg & "Left column: " & lngLeftColumn
MsgBox strMsg
End If
End Sub