Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Center an item in a form with VBA

Status
Not open for further replies.

Huey462

Technical User
Jun 30, 2010
18
US
I have a background form (cleverly called "Background") that has a button on it to open the control panel if the end user manages to somehow close all of the other windows. Is there a way to have access automatically center this button after the form is maximized?

The reason I want to do this is that the control panel Modal is set to “Yes”, making the button on the background form unclickable, if I can “hide” it behind the other form by centering the button it would alleviate some why can’t I click this questions.
 
To center the command button left to right, add this code to the form's resize event:
Code:
Private Sub Form_Resize()
    Me.Command0.Left = (Me.InsideWidth - Me.Command0.Width) * 0.5
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Exactly what I needed.

Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top