G
Guest
I'm trying to identify which records are selected in a subform (datasheet
view). I've got my code working fine, but I can't find which even to put it
behind that it will work 100% of the time.
Some examples of what I've found:
- Putting it behind the "On Click" command will work, as long as you release
the mouse button while your cursor is over the record selector column. If
you move it over the data when you release, the code won't run
- Putting it behind the timer causes all sorts of problems, and never seemed
to kick off when I needed it to
- Putting it behind the On Mouse Up did the same problem as the "On Click
command"
You get the idea on the rest. Just in case, the code I used is below.
Obviously this code just displays the record numbers in a MsgBox, but that is
just to keep this short.
Thanks in advance!
Kevin
*------Code start------*
Dim rs As DAO.Recordset
Dim lng As Long
Dim curTotal As Currency
Dim varPN
Dim varSQL As String
Set rs = Me.RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveFirst
rs.Move Me.SelTop - 1
Do While lng < Me.SelHeight And Not rs.EOF
'here
varPN = rs![PN]
MsgBox varPN
rs.MoveNext
lng = lng + 1
Loop
End If
SumSelectedRows = curTotal
Set rs = Nothing
view). I've got my code working fine, but I can't find which even to put it
behind that it will work 100% of the time.
Some examples of what I've found:
- Putting it behind the "On Click" command will work, as long as you release
the mouse button while your cursor is over the record selector column. If
you move it over the data when you release, the code won't run
- Putting it behind the timer causes all sorts of problems, and never seemed
to kick off when I needed it to
- Putting it behind the On Mouse Up did the same problem as the "On Click
command"
You get the idea on the rest. Just in case, the code I used is below.
Obviously this code just displays the record numbers in a MsgBox, but that is
just to keep this short.
Thanks in advance!
Kevin
*------Code start------*
Dim rs As DAO.Recordset
Dim lng As Long
Dim curTotal As Currency
Dim varPN
Dim varSQL As String
Set rs = Me.RecordsetClone
If rs.RecordCount > 0 Then
rs.MoveFirst
rs.Move Me.SelTop - 1
Do While lng < Me.SelHeight And Not rs.EOF
'here
varPN = rs![PN]
MsgBox varPN
rs.MoveNext
lng = lng + 1
Loop
End If
SumSelectedRows = curTotal
Set rs = Nothing