Query, Table.
You can use the SelHeight property to specify or determine the number of selected rows (records) in the current selection rectangle. 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 have 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.
These properties are not available in Design view. These properties are only available in Visual Basic.
If there is no selection, the value returned by these properties will be zero.
You can use these properties with the SelTop and SelLeft properties to specify or determine the actual position of the selection rectangle on the datasheet. If there is no selection, then these properties return the row number and column number of the cell with the focus.
The SelHeight and SelWidth properties contain the position of the lower-right corner of the selection rectangle. The SelTop and SelLeft property values determine the upper-left corner of the selection rectangle. If there is no selection, then the SelHeight and SelWidth properties are set to zero.
SelTop, SelLeft Properties.
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 lngHeight, lngWidth, lngTop, and lngLeft 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 IfSub