Maximize and center?

G

Guest

When I put this code in the Form's Open event it does maximize the form, but
is there a way to keep the design of the form centered in the window? In
other words, on my login form for example, when the form opens maximized
everything is in the upper left corner of the form, I would like it to be
centered in the window itself.

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
 
R

Rick Brandt

CoachBarkerOJPW said:
When I put this code in the Form's Open event it does maximize the form, but
is there a way to keep the design of the form centered in the window? In
other words, on my login form for example, when the form opens maximized
everything is in the upper left corner of the form, I would like it to be
centered in the window itself.

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub

Not easily. When you maximize you are only making the window maximized. The
size of your form does not actually change.

You would have to run code that determined the size of the window, make the size
of the form agree with that (minus some border amount) and then have code
reposition all of your controls so that they are centered within the new size of
the form.
 
G

Guest

Exactly how tricky is the code and is there somehere I could find an example
of it? Thanks for your reply, that was pretty much the answer I was expecting
but it doesn't hurt to ask the experts.
 

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