Maximizing the Access Window so the form maximizes...

B

Brad Pears

When my app starts up, I want the form to maximize. I issue "docmd.maximize
" in the forms load event and it does maximize to the size of the current
Access window - which unfortunately does not start up maximized.... How pray
tell do I get the main Access 2000 Window to startup "maximized" when the
app is launched? Right now, the user has to manually maximize this window.

It has to be easy!!!

Thanks,

Brad
 
W

Wayne Morgan

One way is to go to the properties of the shortcut you are using to launch
the app and set it's Run property to Maximized on the Shortcut tab.

The following code in the form's module will maximize the Access window and
the form window. The first part goes in the Declarations part of the form's
module, the last part is the form's Load event. It requires the use of
Windows API functions to maximize the Access window. You will find more
options for these here (http://www.mvps.org/access/api/api0019.htm).

Option Compare Database
Option Explicit
Private Const SW_MINIMIZE = 6
Private Const SW_MAXIMIZE = 3
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
Flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long,
lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As
Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As
Long, lpwndpl As WINDOWPLACEMENT) As Long
Dim Rectan As RECT

Private Sub Form_Load()
'Tip submitted by pyp99 ([email protected])
Dim WinEst As WINDOWPLACEMENT
Dim Punto As POINTAPI
Dim rtn As Long
WinEst.Length = Len(WinEst)
'get the current window placement
rtn = GetWindowPlacement(Application.hWndAccessApp, WinEst)
Rectan = WinEst.rcNormalPosition

'set the new min/max positions
Punto.X = 100
Punto.Y = 100
'initialize the structure
WinEst.Length = Len(WinEst)
WinEst.showCmd = SW_MAXIMIZE
WinEst.ptMinPosition = Punto
WinEst.ptMaxPosition = Punto
WinEst.rcNormalPosition = Rectan
'set the new window placement (maximized)
rtn = SetWindowPlacement(Application.hWndAccessApp, WinEst)
'now maximize the form
DoCmd.Maximize
End Sub
 

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

Similar Threads


Top