Maximize Access Application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is it possible to maximize Access via VBA?

I have first.mdb and second.mdb. First.mdb does some stuff and then calls
second.mdb.

Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase second.mdb

I need to be able to maximize the Access Application window (not just the
form window) when it opens using VBA.

How can it be done?

Thanks in advance for your help!
 
Hi Peter

You need to make a call to the Windows API. First declare the ShowWindow
function:

Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) _
As Long

.... and a necessary constant (to make your code more readable):

Private Const SW_SHOWMAXIMIZED = 3

Then, perhaps a jacket procedure:

Public Sub MaximizeWindow( hWnd as Long)
ShowWindow hWnd, SW_SHOWMAXIMIZED
End Sub

(all of the above in a standard module)

And then you can use it thus:

MaximizeWindow appAccess.hWndAccessApp
 
Doug...

Thank you for responding but I tried putting the appAccess.DoCmd.Maximize
before the appAccess.OpenCurrentDatabase second.mdb and after it and neither
way maximized second.cmd.

Any other ideas? Thanks again!
 
Thank you Graham....it worked beautifully!

Graham Mandeno said:
Hi Peter

You need to make a call to the Windows API. First declare the ShowWindow
function:

Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) _
As Long

.... and a necessary constant (to make your code more readable):

Private Const SW_SHOWMAXIMIZED = 3

Then, perhaps a jacket procedure:

Public Sub MaximizeWindow( hWnd as Long)
ShowWindow hWnd, SW_SHOWMAXIMIZED
End Sub

(all of the above in a standard module)

And then you can use it thus:

MaximizeWindow appAccess.hWndAccessApp

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



PeterM said:
is it possible to maximize Access via VBA?

I have first.mdb and second.mdb. First.mdb does some stuff and then calls
second.mdb.

Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase second.mdb

I need to be able to maximize the Access Application window (not just the
form window) when it opens using VBA.

How can it be done?

Thanks in advance for your help!
 
Graham Mandeno said:
Hi Peter

You need to make a call to the Windows API. First declare the
ShowWindow function:

Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) _
As Long

... and a necessary constant (to make your code more readable):

Private Const SW_SHOWMAXIMIZED = 3

Then, perhaps a jacket procedure:

Public Sub MaximizeWindow( hWnd as Long)
ShowWindow hWnd, SW_SHOWMAXIMIZED
End Sub

(all of the above in a standard module)

And then you can use it thus:

MaximizeWindow appAccess.hWndAccessApp

Is there some reason not to just use the built-in ...

appAccess.RunCommand acCmdAppMaximize

?
 
Hi Dirk
Is there some reason not to just use the built-in ...

appAccess.RunCommand acCmdAppMaximize

Maybe just because I wrote my code long before acCmdAppMaximize was invented
<grin & blush>

Cheers,
Graham
 
Back
Top