Centering a Form

R

Rob

How can I use VBA to always make sure a form is centered
when it is displayed on screen?

I have a Main Form. I have the AutoCenter set to "yes".
It works well when I first open the database. But I have
other forms that have cmd buttons that open open the Main
Form. This is when it does not center.

Any help?? Thanks.
 
D

Dirk Goldgar

Rob said:
How can I use VBA to always make sure a form is centered
when it is displayed on screen?

I have a Main Form. I have the AutoCenter set to "yes".
It works well when I first open the database. But I have
other forms that have cmd buttons that open open the Main
Form. This is when it does not center.

Any help?? Thanks.

I don't reproduce the problem. What code are you using to open the form
in your command buttons? What are the form's PopUp and Modal
properties? (Not that I know these are relevant) Is there any code
behind the form or the buttons that moves it or resizes it?
 
R

Rob

Here is the code for the cmd button that opens the "Main
Menu" Form from the "Hous Auth Request" form.


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Main Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Hous Auth Request"

Modal and Pop Up are set to "No"
 
D

Dirk Goldgar

Rob said:
Here is the code for the cmd button that opens the "Main
Menu" Form from the "Hous Auth Request" form.


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Main Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Hous Auth Request"

Modal and Pop Up are set to "No"

Unfortunately, I don't see any reason that form wouldn't open centered
if its AutoCenter property is set to Yes. When I test on a form of my
own, it works fine. Are you sure there's no code behind the "Main Menu"
form that affects its position? No "DoCmd.MoveSize" or
"DoCmd.Maximize"?
 

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