dynamically reposition controls on a form

J

Jay

Is there a way to know the positioning coordinates of a control on a form?
I need a routine that will for example "move all controls on the form 1 inch
to the right".
The code below would work if I had the value for the variable oldPositionX,
but I cannot figure out how to know this dynamically.
Thanks very much.

Dim ctl As Control, cnt As Integer
For Each ctl In Forms(formName).Controls
ctl.Move oldPositionX + 1440
Jay
 
G

Granny Spitz via AccessMonster.com

Jay said:
Is there a way to know the positioning coordinates of a control on a form?
I need a routine that will for example "move all controls on the form 1 inch
to the right".
The code below would work if I had the value for the variable oldPositionX,
but I cannot figure out how to know this dynamically.

You're so close! You just need to give the control's Left property for its
current horizontal position, and the control's Top property for its vertical
position (in case you need that in the future). Try it like this:

Dim ctl As Control
Const INCH As Long = 1440

For Each ctl In Forms(formName).Controls
ctl.Move ctl.Left + INCH
Next ctl

Set ctl = Nothing
 

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