SetGetScrollBars.zip is a database containing functions to allow a user to programmatically set the position of a Form's Scrollbar in Continuous Forms or Datasheet view.
NEW - Feb. 20/2000 Ver 1.0. SetGetScrollBars Replaces the older SelectARow functions for scrolling Forms. I have a new function for Scrolling List/Combo controls as well that I will post in the next week as well.
If you do not need the full control available in SetGetScrollBars but just need to Scroll your Form or SubForm, you can use the following code.
it is straightforward to Scroll a Form's ScrollBars.
is a database containing 2 Functions with Source Code.
2) Function to allow you to specify where the Selected Row in a Continuous Form
will be displayed.
I ran into this problem several months ago. The standard Access ListBox control does not expose a property allowing you to specify what row is the first displayed row in the ListBox. Well, we have to do it the hard way. I have successfully used 2 different methods.
A) API SendMessage with a VSCROLL Message to simulate the user manually changing position with the ScrollBars.
Place the following code behind the Click
event of a Command Button. You'll just need to calculate how many pages and
lines to scroll down based on the height of your ListBox and the row
you need to select.
'So I used the 15th row in the the zero based index for this example. The ListBox is named List4.
have scrolled down 1 page in the ListBox
B) Let's Jump through some hoops! :-) This will allow us to specify exactly where we want a specific row to appear in the List Box. The logic here is to Select the row you want displayed in the usual manner, directly with a value as in List Box = CustomerId or with one of the Index properties, like List Box = ListBox.ItemData(0). You can then apply the following function to resize the List Box so that the row you selected is displayed in the specified position.
how to make a ListBox scroll to or
Form/ SubForm Select where a Specific Row is Displayed
Generally, this question pops up in relation to data entry in a Form/SubForm. When a record is added/deleted or saved a Requery is often issued. After a requery the recordset defaults to showing the first record at the top of the Form. If the user was say working on the 150th record, it is disconcerting to say the least to have to scroll back to the record they were working on prior to the requery.
a couple of different ways to handle this. Here's a few I've used.
3) Use the SendMessage API with VSCROLL messages to force SubForm to scroll back to the required position.
OK, for most situations, one of the above 3 methods will work fine. Still, you'll notice that the row we've selected appears as the top row displayed in the Form. Again this can be disconcerting to the user if the record they were working on prior to the Requery was at say the bottom of the screen. In order to restore the displayed order of the rows after a Requery requires jumping through a lot of hoops. I don't personally feel it is worth it but that's up to you. There is a sample database in this archive detailing what hoops to jump through. Have fun!
I haven't updated this file in a while. I have recently had better success, with a lot less hassle, using SelTop and SendMessage with VSCROLL together. I'll try to find time to update this in the future. :-)