How to get Current Record from the subform with the datasheet

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hello,

I run Access 97 on Win XP.
I want to refer to a current record on the subform that displays multiple
records on a datasheet. When I refer to ME("field_name").value I get the
value of a field from the first record of a datasheet.
How to get a value of the current record that the cursor is on.

Any help is greatly appreciated,
Tom
 
Hi,


In fact, it is not the first record, but the one actually 'in focus'.
If all you want is to see ONE record, instruct the end user to CLICK on the
record, instead of just moving the mouse over it.

In what follow, I assume you need a reference to TWO records, the actual
one, in focus, and another one. To get it as you want, as your mouse move
over to go to... who knows where... but still, you wish to take a look at
the record "under the mouse", you have to make some computation as to know
the difference in position between the record in focus and the mouse
position (on mouse move event), then, through the recordset clone (already
open for you, for a bounded form) that you would have synch
(Me.RecordsetClone.Bookmark = Me.Bookmark) with the actual record in focus,
make a relative record move and then, finally, read, from the clone, the
information you seek. I think Stephen did make a lot of the required
computations, in a way or in another, not necessary exactly to accomplish
exactly what you tried to achieve, so you may take some time in exploring
his site (http://www.lebans.com/).

An alternative, do the reverse (always assuming you wish to examine TWO
records at a time), implement a "PreviousRecord", a local variable you
"push" appropriately in the onCurrentEvent:

' in the form declaration
Dim PreviousBookmark As Variant
Dim WouldBecomePrevious As Variant


' near the beginning of the onCurrentEvent

PreviousBookmark= WouldBecomePrevious
WouldBecomePrevious=Me.Bookmark
'so, next time the onCurrent fires, we would know
' which record was the "previous one"





and then, instead of a mouse-over, instruct the end user to CLICK on the
record, and, through the use of the bookmarks, you can related the actual
record AND the previous one VISITED. The end effect is the same, but I
admit, it is a little bit awful with because the User Interface "syntax" is
then noun-noun-verb, ie, selection the two records, then the action to
perform between them, rather than a more intuitive UI-syntax such as
subject-verb-complement (select a record, select an action to be made,
select the partner of the action, here the second record). A nice UI is
important, but delivery time of the product is also important, you know
better than me the issues of your case... there are so many solutions... :-)



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top