PDA

Click to See Complete Forum and Search --> : In Access, resize size application to size form


le_highlander
Sep 12th, 2005, 05:37 PM
Hello,

I'm using Access.

I want to specify the size of the application (Access) to be adapted with the size of a form (which dimensions can't be changed) and i want the form to be anchored on the top left of the application. I thought to put the code in the Form_load.

I found a lot of threads that deal with resizing but all of them seem to answer the problem 'size of the controls' with 'size of the form'.

If someone can help me !

Thanks by advance.

AIS4U
Sep 12th, 2005, 10:08 PM
Hey le highlander:

I am not exactly sure if I understand what it is you want to do, but it sounds like you want the form to appear in a certain area of the screen when you run your application and also to have all your controls appear in a certain area on the form.

If, for example, you want to application to fill the entire screen you would use the WindowState property. This can be set at design time or at run time. At design time just select WindowState in the properties window and select either 0-normal, 1, minimized, or 2, maximized. You can also do this with code in the form load event as you stated. Just use WindowState = 2 or whichever choice (0 - 2) that you desire.

If you want to make your form appear in a certain area on the screen you can use code in the form load event such as: Me.Move 2700, 3000

The 2700 is the distance from the left side of the screen and the 3000 is the distance from the top of the screen (assuming you set the WindowState property to 2-Maximized). This in in pixels. You can play around with the numbers until you get a feel for it and adjust the numbers according to where you want your form to appear.

If you want to make your controls appear in a certain location on your form, you do much the same thing. To do this you can set the left and top properties for each control in reference to your form. Again this can be done through the properties windows or in your code.

I hope this helped.

Good Luck

le_highlander
Sep 12th, 2005, 10:31 PM
hello

Thanks for your response.
When i read what you wrote, it seems to be what i want. But it doesn't work when i put it in the form_load (Me.Move ....). Is says 'Compilation Error'.

dglienna
Sep 12th, 2005, 10:37 PM
Don't you want ACESS to line up with a VB form?

le_highlander
Sep 12th, 2005, 10:39 PM
yes it's what i want

RobDog888
Sep 12th, 2005, 10:56 PM
Moved to Office Development forum. ;)

le_highlander
Sep 12th, 2005, 11:03 PM
sorry to have put the thread at the wrong place

RobDog888
Sep 12th, 2005, 11:06 PM
Its not a problem. ;) It takes members a while to get a feel for the Forums and where their threads are best suited. :)

JustinLabenne
Sep 13th, 2005, 06:36 AM
Not what you want, but why not just size the form with Access as maximized. It pseudo-hides Access behind the form.

Private Sub Form_Load()
DoCmd.Maximize
End Sub

Or you can make Access hidden while the form is shown. Probably less code required with these two manners, but the latter requires some api.

Also, the MoveSize Command:
Private Sub Form_Load()
Application.DoCmd.MoveSize 100, 5, 5000, 5000
End Sub

le_highlander
Sep 13th, 2005, 03:20 PM
The MoveSize command was very useful ! Is there a way to size the Access window ?

RobDog888
Sep 13th, 2005, 04:09 PM
You would probably have to use some APIs to resize the main app window as it only allows for the 3 window states and doesnt ahve a size window property or method. :(

RobDog888
Sep 13th, 2005, 04:17 PM
This should resize the mailn application window to what ever size you need. ;)
Option Explicit
Option Compare Database

Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Sub ResizeApp()
'Resize main app window to 700 high x 1000 wide
'x and y are the orgin of the top/let corner
'cx and cy are the size of the window.
Application.RunCommand (acCmdAppRestore)
SetWindowPos Application.hWndAccessApp, 0, 0, 0, 700, 1000, 0
End Sub

le_highlander
Sep 13th, 2005, 05:15 PM
ohhhhhhh it's beautiful !

thanks a lot.

RobDog888
Sep 13th, 2005, 05:17 PM
Finally, someone that appreciates the true beauty of my code! Thanks :thumb: :D

JustinLabenne
Sep 13th, 2005, 08:50 PM
Can't say I have ever resized the app window to meet the form window (usually the other way around) very nice code RobDog888. :thumb:

RobDog888
Sep 13th, 2005, 08:53 PM
Thanks Justin. I too usually do it the other way around but have used this code before on VB6 forms for various things. I never thought t would work for this but Access is also just a regular MDI window so I guess its logical. ;)