Today I had a control that I wanted to place right at the center of my popup form. I could get it roughly right in design mode, but just not 100% there.
Thankfully Access vba can be used to write developer helper functions as well as codes for the user interface. So I came up with this simple function that centers a control on a form, based on the width of the form. I used it while I had my form open in design view, and the button I wanted to center was selected.
Public Sub CenterActiveControl()
On Error Resume Next
Dim ctl As Control
Set ctl = Screen.ActiveControl
ctl.Left = GetControlParentObject(ctl).Width / 2 - ctl.Width / 2
Set ctl = Nothing
If Err.Number <> 0 Then
MsgBox "Could not center control" & vbNewLine & Err.Number & " - " & Err.Description
On Error GoTo 0