Option Group Top Property

G

Guest

Greetings. Using Access 2003. I'm trying to dynamically reposition and
resize controls on a form at run time. Code is working great with one
exception: Option Groups. I've noticed as soon as I adjust (increase) the
Top property of the Option Group frame it doesn't move, it stretches. I can
watch the Height property in the Immediate wdw and verify the as soon as I
increase Top, Height increases by the same amount.

The upshot is that I want to MOVE the Option Group, not stretch it. Funny
that Top works as a coordinate position for every other ControlType. I'm
sure that it has something to do with the parent/child relationship the frame
has with its members, but can anyone offer advice and/or snippets of air code
for moving an Option Group?
 
A

Allen Browne

The reason it stretches is that the option buttons have to remain in the
group, but you have not moved them yet. Access considers their position
relative to the form, not the option group, so they don't move when you move
the group.

The workaround is to set the Top and Left property of the group, then the
option buttons, then the labels of the option buttons, and finally set the
Height and Width of the group to the right size again. That should be more
efficient than iterating through the group, buttons, and labels moving them
all by small increments until they arrive at their destination, but it might
depend which direction you are moving them.
 
G

Guest

Thanks Allen. Now that I think about it (and with your comments), this
behaviour does make sense. Here's what ended up working for me in case
anyone else were to find this thread in a search (tested only in Access 2003):

I didn't have to adjust any properties of the option group frame prior to to
moving objects within it and around it. It turns out that if you move one of
its child objects beyond the boundaries of the frame, the frame automatically
stretches to still enclose it.

In code, I start by iterating through all controls in the form, stopping to
capture current unchanged Top, Left, Height and Width properties of only the
Option Groups (if there are any on the form). I store the values in a
user-defined type array, redimming on each found Option Group. I then
iterate through all the controls a second time, EXCLUDING the Option Groups,
making changes to those 4 properites to adjust position and size. The frame
size on each Option Group will have been altered in this step because its
members moved. Finally, I check for any hits in my UDT array. If any
exists, I loop through them and use the original values to calculate what
Top, Left, Height and Width SHOULD be, and set them for each frame.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top