Question : Selecting VBA Frame changes Parent Frame Scroll position

Hi, I have an Excel form containing a Frame, within which there are a number of other frames (all  aligned vertically)

The Parent Frame has a vertical scroll bar allowing the user to navigate from Frame to Frame.

We have found that if the user is working withing one frame, and then clicks into a different frame, the Parent Frame Scroll Top is set to the top of the visible area.

A lot of the time, this doesnt matter - if the users has got tot he bottom of Frame 1, and clicks into Frame 2, we don't mind if Frame 2 shifts up a bit.    

But, some of our fames are taller than the form height, the user may Scroll down to the control they are after, click it , and then find the frame has paged back up to the top.

Does anyone know how I can disable this sort of behavior?

I have tried capturing the Scroll top position (using the Frame.Exit event - and setting the Scroll top on the new frame's Enter event), but to no evail, as the re-positioning happens after Frame.Enter

Answer : Selecting VBA Frame changes Parent Frame Scroll position

Hy again,
Every time you move from one frame to another, the Scroll event of the Parent Frame (Frame1) triggers automatically. In fact it is triggered by the new frame that you are moving in.

If you analyze the parameters of the Scroll event when it is triggered, you will see that the ActionX and ActionY equals 10. The 10 value is actually a constant named 'fmScrollActionFocusRequest' and it is described as the following:
fmScrollActionFocusRequest  means that "The user moved the focus to a different control. This movement scrolls the user form so that the selected control is fully displayed in the available area".
You can also check the Object Browser for the Members of the 'fmScrollAction'.

So far I couldn't find a method for preventing this automatically fired event nor to cancel it.

Cristi
Random Solutions  
 
programming4us programming4us