Center form by VBA

  • Follow


Hello All-

I have a form that acts as a splash screen, gives the title of the
application and a graphic while items load in the background.  I am trying to
use the Docmd.MoveSize function to center this form in the application window.
When the application starts, this form will be the only one open for several
seconds so it will be against the gray background of the Access Window.  

I thought I could use the following code, but it seems to be trying to center
the database tray.

intScreenHeight = Me.InsideHeight
        intScreenWidth = Me.InsideWidth
        
        intScreenHeightHalf = intScreenHeight / 2
        intScreenWidthHalf = intScreenWidth / 2
        
        intFormHeight = (2.291 * 1440)
        intFormWidth = (5.3326 * 1440)
        
        intFormTop = intScreenHeightHalf - (intFormHeight / 2)
        intFormLeft = intScreenWidthHalf - (intFormWidth / 2)
        
        DoCmd.MoveSize intFormLeft, intFormTop, intFormWidth, intFormHeight


Any thoughts would be great.

Thanks
Chris

-- 
Message posted via http://www.accessmonster.com

0
Reply SurveyorinVA 1/9/2008 9:39:11 PM

I thought that if a form had its Auto Center property set to Yes, it would 
automatically be centred in the application window.

Jeanette Cunningham


"SurveyorinVA via AccessMonster.com" <u19217@uwe> wrote in message 
news:7df8244c888be@uwe...
> Hello All-
>
> I have a form that acts as a splash screen, gives the title of the
> application and a graphic while items load in the background.  I am trying 
> to
> use the Docmd.MoveSize function to center this form in the application 
> window.
> When the application starts, this form will be the only one open for 
> several
> seconds so it will be against the gray background of the Access Window.
>
> I thought I could use the following code, but it seems to be trying to 
> center
> the database tray.
>
> intScreenHeight = Me.InsideHeight
>        intScreenWidth = Me.InsideWidth
>
>        intScreenHeightHalf = intScreenHeight / 2
>        intScreenWidthHalf = intScreenWidth / 2
>
>        intFormHeight = (2.291 * 1440)
>        intFormWidth = (5.3326 * 1440)
>
>        intFormTop = intScreenHeightHalf - (intFormHeight / 2)
>        intFormLeft = intScreenWidthHalf - (intFormWidth / 2)
>
>        DoCmd.MoveSize intFormLeft, intFormTop, intFormWidth, intFormHeight
>
>
> Any thoughts would be great.
>
> Thanks
> Chris
>
> -- 
> Message posted via http://www.accessmonster.com
> 


0
Reply Jeanette 1/9/2008 9:48:25 PM


1 Replies
1139 Views

(page loaded in 0.018 seconds)

Similiar Articles:
















7/28/2012 7:50:50 AM


Reply: