how many rows selected

  • Thread starter Thread starter Graeme Richardson
  • Start date Start date
G

Graeme Richardson

I have a form opened in datasheet view. Say I select 5 records by clicking
and dragging over the record selectors. Is it possible to get the ids of
these 5 records in VBA?

Thanks for your help, Graeme
 
I studied the properties and methods a little harder and came up with this
code:

' Starts here
Dim rst As DAO.Recordset
Dim lngTop As Long
Dim lngHeight As Long
Dim lngCount As Long

lngTop = Me.SelTop
lngHeight = Me.SelHeight

Set rst = Me.RecordsetClone
' Refresh the recordset
rst.MoveLast
rst.MoveFirst

If lngTop <= rst.RecordCount Then
' User has selected live records
If lngTop + lngHeight - 2 >= rst.RecordCount Then
' User has selected live records and the new record at the
bottom of the form
lngHeight = lngHeight - 1
End If

rst.AbsolutePosition = lngTop - 1
For lngCount = lngTop To lngTop + lngHeight - 1
Debug.Print rst("uidFish")
rst.MoveNext
Next

Else
' User has selected the new record at the bottom of datasheet only
End If
' Stops here

Enjoy.
 
Back
Top