PDA

View Full Version : Moving Frames In A Userform



kestrel1306
12-11-2016, 05:44 PM
Hi team,

I have a long userform, that is used for data entry.

At certain points I want to move a frame that was previoulst 'hidden' below the visible length of of the userform and insert it further up, obviously everything further down gets relocated.

Easy with one frame to move.

I'm now upping the degree of difficulty and want to do the same with four frames (and beginning to regret it).

Whats a simple way to organise the code please, currently with one I can just change the TOP value, and the SCROLLHEIGHT value and everything shuffles down nicely.

With four to move and my limited skills, the only way I can currently see to do it is a million if thens to try and cope with each possible scenario (16 in total I guess).

Any way would be gratefully welcomed.


Regards
Kestrel

gmayor
12-11-2016, 09:46 PM
Why not use a multi-page frame and use the tabbed pages, which you can make visible or not as required and it's a lot less trouble to do that than move fixed frames around? Put your frames on the four pages. See http://www.gmayor.com/ManyToOne.htm and http://www.gmayor.com/interactive_multichoice.html for examples of this used in practice.

You might find it easier with fixed frames to move them off to the right rather than to the bottom.

kestrel1306
12-12-2016, 03:05 PM
Hi Graham,

Thanks for the quick reply, I wasn't originally going to go with a multipage, but occams razor wins out.

Thanks very much for your advice.


Regards
Kes

SamT
12-12-2016, 03:51 PM
Whats a simple way to organise the code please, currently with one I can just change the TOP value, and the SCROLLHEIGHT value and everything shuffles down nicely.

With four to move and my limited skills, the only way I can currently see to do it is a million if thens to try and cope with each possible scenario (16 in total I guess).

When I have to,I use a ControlLocation Array or Collection.

As needed, load the Frame names into the array in desired order, then it's just a matter of adding thier heights and a fixed separation value

Dim Bottom as long
Const FixedTop As long = ?
Const SepVal As Long = ?

ControlLoc(0).Top = FixedTop
Bottom = FramesTop + ControlLoc(0). height

For i = 1 to 3 '(Controls.Count - 1)
ControlLoc(i).Top = Bottom + SepVal
Bottom = Bottom + Control(i).Height

This simple loop works for any number of Controls

There are simple codes to manage the order of Controls in ControlsLoc; Reset to a default order, place any one at the top and shift the rest down, etc.