Centering a Form

  • Thread starter Thread starter Rob
  • Start date Start date
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.
 
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?
 
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"
 
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"?
 
Back
Top