A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Center form by VBA



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2008, 09:39 PM posted to microsoft.public.access.forms
SurveyorinVA via AccessMonster.com
external usenet poster
 
Posts: 5
Default Center form by VBA

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

  #2  
Old January 9th, 2008, 09:48 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Center form by VBA

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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.