Link to home
Start Free TrialLog in
Avatar of Dale Fye
Dale FyeFlag for United States of America

asked on

Determine which record is displayed at top of continuous form when user uses the scroll bar to scroll down

I'm trying to determine the PK of the record displayed at the top of a continuous subform.

I have a subform which contains times from 07:30 - 17:00 in 15 minute intervals.  Unfortunately, I can only display about 20 of these records at one time, so I have the vertical scrollbar enabled.  If the user scrolls down, using the vertical scroll bar, I want to be able to determine what time interval is locate at the top of the visible section of the subform.

I know that if the user scrolls down and then selects the top most record, I can use the SelTop property of the form, but this value does not change unless the user actually selects the record at the top of the form.  Any ideas:
1.  What event to use to check whether the user has scrolled down
2.  how to determine the time associated with the record displayed at the top of the form.

Thanks,

Dale
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Probably if you study the code from Leban's ContinuousFormsCurrentRow you could tackle this...it has being quite some years i fiddled it with it but if my memory serves e right you will able to "decode" the Continuous form Vertical location so you could find out the upper- lower bounds of it...
Someone also had the ability to read the position of the thumb on the scroll bar, but memory fails me at the moment :(

Also I don't think it would have been accurate enough to get a specific record.

Jim.
The code of Lebans i think it does that.....if there is another implementation of CF thumb it would be extremely interesting Jim to find and share it....from my search something like this has being done for ActiveX ListView.
Avatar of Dale Fye

ASKER

Actually, Steve's code does not work correctly, at least not when converted to A2007, and in order for it to work, you have to mouse over the records, which I don't want to have to do.  Additionally, the data displayed at the top of the form, when you mouse over the Code field of the first record displays the data for the 2nd record.  Then, as you scroll down, it displays the data corresponding to the record above it, not the one that the mouse is over.  Furthermore, if you actually move the scrollbar down to display records 5-9, and mouse over record 5, it will display the data from record 1 (the second record displayed when the scrollbar is all the way up).

I think what I'm really looking for is the number (X) which displays in the control tip when you click and drag on the scroll bar (X of Y).  I'm not aware of a scrollbar event, though so I don't know how to get that value.
Hi Dale,
I've never actually tried to use the sample code but maybe you can create your own scrolling.  I don't like hardcoding things but since you know you can only show 20 rows, perhaps you can use that to your advantage by selecting ONLY 20 rows at a time.  That way you always know what row is at the top.  You can create 6 down and  up buttons - Top, Bottom, down 1, down 5, up 1, up 5
That's an excellent thought Pat.

Jim.
Pat,  That was my fall-back position, if I couldn't find someone who knew how to do this.  Unfortunately, that doesn't handle the situation where the user actually selects a record and then uses the up and down arrows to move up and down through the recordset.  I'll have to do some more thinking on this.

Seems strange that there is not method or property of the form that would provide that info.  Sounds like a UserVoice request.
<<Pat,  That was my fall-back position, if I couldn't find someone who knew how to do this.  Unfortunately, that doesn't handle the situation where the user actually selects a record and then uses the up and down arrows to move up and down through the recordset.>>

 Capture the up/dwn and either eat them up, or use that to control your custom scrolling.  Ditto for page up/down.

Jim.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Jim, I'll take a look.
Jim, that was precisely the solution I was looking for.

I'm disappointed that there is no scroll bar event that we could use to trigger this info, but I guess I'll do as Stephen did and use timer event.

Thatnks John and Pat for your suggestions.
You're welcome.  Please post any improvements to the Leban's code you come up with.
<<Jim, that was precisely the solution I was looking for.>>

 Glad to hear it pretty much got you where you need to be.

<<I'm disappointed that there is no scroll bar event that we could use to trigger this info,>>

  There's more than a few things we'd all love to see in Access.   It's too bad that Microsoft focused on the web for so long.   I understand why, but they really could have made Access a lot better for the desktop had they not.

Jim.