Set the size of the Access Database Window

J

JR_06062005

I need to maximize the size of the Access database window. I know how to
maximize a form and also pop-ups which will maximize to the screen size. But
a pop-up is not a good option for this particular case because I want the
user to be able to use a customized toolbar. In reading this group, someone
suggested the following code:
Dim objacc As AccessObject
objacc.RunCommand acCmdAppMaximize
When I try to run the code, I get the error message "Object variable or with
block not set". I think I'm supposed to set the objacc to some value, but
I'm not sure how to do works.
 
S

Stuart McCall

JR_06062005 said:
I need to maximize the size of the Access database window. I know how to
maximize a form and also pop-ups which will maximize to the screen size.
But
a pop-up is not a good option for this particular case because I want the
user to be able to use a customized toolbar. In reading this group,
someone
suggested the following code:
Dim objacc As AccessObject
objacc.RunCommand acCmdAppMaximize
When I try to run the code, I get the error message "Object variable or
with
block not set". I think I'm supposed to set the objacc to some value, but
I'm not sure how to do works.

You could give this a try:

http://www.smccall.demon.co.uk/Windows.htm#SizeAccess
 
J

JR_06062005

Thanks Stuart. Very good website and the code works great. I have marked
your website as a favorite. It is loaded with great information.

I have 3 follow-up questions: 1) Is there a way to determine the size of
someone's existing Access Window? 2) Is there a way to determine the size of
someone's screen? and 3) I have a Windows toolbar which is set to always be
on top. When I re-size the Access to maximum, the control box, with the
maximum, minimum and close (has an X for close) controls, is hiden behind the
toolbar. Is there a way to size the window so that the window adjust to a
maximum size so that the control box does not go behind the toolbar? (I hope
the 3rd question makes sense)
 
S

Stuart McCall

JR_06062005 said:
Thanks Stuart. Very good website and the code works great. I have marked
your website as a favorite. It is loaded with great information.

I have 3 follow-up questions: 1) Is there a way to determine the size of
someone's existing Access Window? 2) Is there a way to determine the size
of
someone's screen? and 3) I have a Windows toolbar which is set to always
be
on top. When I re-size the Access to maximum, the control box, with the
maximum, minimum and close (has an X for close) controls, is hiden behind
the
toolbar. Is there a way to size the window so that the window adjust to a
maximum size so that the control box does not go behind the toolbar? (I
hope
the 3rd question makes sense)

For your questions 1 and 2, you have the code there already to enable you to
roll your own functions, specifically the line:

GetWindowRect GetDesktopWindow(), r

That fills the Rect structure r with the screen coords. Screen width is
r.x2 - r.x1. Screen height is r.y2 - r.y1.

To get the Access main window size, use:

GetWindowRect Application.hWndAccessApp, r

then do the math in the same way.

Question 3 does not compute. If your toolbar is set to be 'always on top',
then you can't really expect a window (Access form or otherwise) to overlay
it.
 
J

JR_06062005

Sorry my 3rd question didn't make sense. Perhaps the best way to describe
what I am getting at is to describe the VB commands for Excel, Word and
PowerPoint which achieve what I would like to do in Access:

Excel: Application.WindowState = xlMaximized
Word: Application.WindowState = wdWindowStateMaximize
PowerPoint: Application.WindowState = 3

All the above commands give me a maximized window for their respective
programs. The maximized window is within the frame of the windows toolbar,
which avoids the problem of some of the contorl box of the window (which is
in the upper right corner of the window) being hidden behind the toolbar. My
toolbar is along the right side of my screen. Is there an equivalent command
in Access and if not, how can I achieve the same effect in Access?
 
S

Stuart McCall

JR_06062005 said:
Sorry my 3rd question didn't make sense. Perhaps the best way to describe
what I am getting at is to describe the VB commands for Excel, Word and
PowerPoint which achieve what I would like to do in Access:

Excel: Application.WindowState = xlMaximized
Word: Application.WindowState = wdWindowStateMaximize
PowerPoint: Application.WindowState = 3

All the above commands give me a maximized window for their respective
programs. The maximized window is within the frame of the windows
toolbar,
which avoids the problem of some of the contorl box of the window (which
is
in the upper right corner of the window) being hidden behind the toolbar.
My
toolbar is along the right side of my screen. Is there an equivalent
command
in Access and if not, how can I achieve the same effect in Access?
<SNIP>

Gotcha. This will give you the screen size so you can size the form to the
desktop's 'working area', ie all the screen space but for windows
toolbar(s):

''' BEGIN CODE '''
Private Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type

Private Const SPI_GETWORKAREA& = 48

Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
lpvParam As Any, _
ByVal fuWinIni As Long) As Long

Function DesktopClientArea() As Rect
Dim r As RECT
SystemParametersInfo SPI_GETWORKAREA, 0&, r, 0&
DesktopClientArea = r
End Function

Sub Test()
Dim r As Rect
r = DesktopClientArea()
Debug.Print "Height = ";r.y2 - r.y1
Debug.Print "Width = ";r.x2 - r.x1
End Sub
''' END CODE '''
 

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

Top