Forcing Access applications to start in a specific window size

BrettM

just a pert, "ex" to come
Local time
Tomorrow, 06:39
Joined
Apr 30, 2008
Messages
134
I had previously offered a user on this forum a piece of code I have been using to force Access to start in a particular window location and in a specific sized window. It works marvelously... 99% of the time. Sometime however, after ALT-TABing to another application, Access has decided to redisplay maximised. Is there a conditional statement in Access to force the display to "Restore Down" and remove the Minimise and Maximise buttons off the application or is that outside of Access?

The code I use is as follows...
Using a Master Module, in the global declarations ...
Code:
'NOTE: The following "Declare" statement is case sensitive.
Declare Sub SetWindowPos Lib "User32" (ByVal hWnd&, ByVal hWndInsertAfter&, ByVal X&, ByVal Y&, ByVal cX&, ByVal cY&, ByVal wFlags&)
'Moves MS Access window to top of Z-order.
Global Const HWND_TOP = 0
'Values for wFlags.
Global Const SWP_NOZORDER = &H4      'Ignores the hWndInsertAfter.
Create a Function in the module...
Code:
Function SizeAccess(cX As Long, cY As Long, cHeight As Long, cWidth As Long)
   Dim h As Long
   'Get handle to Microsoft Access.
   h = Application.hWndAccessApp
   'Position Microsoft Access.
   SetWindowPos h, HWND_TOP, cX, cY, cWidth, cHeight, SWP_NOZORDER
End Function

and in the Form_Open sub of the main DB form...
Code:
Call SizeAccess(X Pos, Y Pos, Height, Width)

Any suggestions would be great.
 
Try the On Resize event
 

Users who are viewing this thread

Back
Top Bottom