I'm working in Access 2013 and have a number of controls (listboxes, buttons, etc.) that I want to keep centered, as a group, on a form when the form is resized.
Anchoring won't accomplish what I'm looking for because I don't want to lock the controls to the top/bottom/left/right. I want them to stay in the center.
Simply using code like this me.mycontrol.left = myform.Width/2 on the form's resize event doesn't do what I'm looking for because it aligns the individual controls to the center. I want the group of controls to be centered.
Is there a way to do this?
EDIT: Here's an example, which may make this clearer. Suppose I have a 100 x 100 form with two buttons on it. The buttons are 20 units tall and are spaced 10 units apart. They'd have the following positions:
Button1.Top = 25 (10 unit space starts at 45) Button2.Top = 55
If the form is resized to 200 x 200, the controls would have the following positions:
Button1.Top = 75 (10 unit space starts at 95) Button2.top = 105
Ideally, I'd love to turn this into a module, where I just pass it a form and it takes the original position of each control and calculates the new position.
Edit 2:
Here's one failed attempt at it, using my real code, based onthe idea from Krish:
Private Sub Form_Resize()
Dim resizeFactor As Double
resizeFactor = Me.WindowWidth / Me.Width
Me.lstModule.Left = Me.lstModule.Left * resizeFactor
Me.ctlSubform.Left = Me.ctlSubform.Left * resizeFactor
Me.Box6.Left = Me.Box6.Left * resizeFactor
End Sub