Access screen size

  • Thread starter Thread starter swas
  • Start date Start date
S

swas

Hello,

I'm trying to determine the size of the main Access window. I assumed it
would be part of the application object, but can't find anything, nor in
searching help here.

Is this readily available?


Thanks in advance


swas
 
Rob,

Thanks for the reply.

I haven't tried the code, but from what it reads, it returns the main screen
size.

I'm after the Access main window size. I want to display a popup form, but
want to put it over to the right of the main window, out of the way of other
Access forms since it will be kept on top while doing work.


Thanks


swas
 
swas said:
Rob,

Thanks for the reply.

I haven't tried the code, but from what it reads, it returns the main
screen
size.

I'm after the Access main window size. I want to display a popup form, but
want to put it over to the right of the main window, out of the way of
other
Access forms since it will be kept on top while doing work.


Thanks


swas

Here's one way (air code) :

Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, lpRect As Rect) As Long

Public Function AccessSize(pHeight, pWidth) As Boolean
Dim r As Rect
On Error Goto ExitPoint
GetWindowRect Application.hWndAccessApp, r
pHeight = r.Bottom - r.Top + 1
pWidth = r.Width - r.Left + 1
AccessSize = True
ExitPoint:
End Function

Paste the above code into a new, standard module, then call it like this:

Dim AccessHeight, AccessWidth

If Not AccessSize(AccessHeight, AccessWidth) Then
'An error occurred
Else
Debug.Print AccessHeight, AccessWidth
End If
 
Hi again swas,

I've seen the follow-up to my reply posted by Stuart McCall, and that may
help you.

But if it doesn't, I'm sorry that I can't help further. Except for these
comments (on an area that I'm not exactly expert in):

The API I referenced will return either the overall windowsize available to
the application (if it's maximized - via the call
fGetSysStuff("windowsize") ), or the screen resolution (via the call
fGetSysStuff("resolution") ); the first of these take into account any
system toolbars which are present. In either case, you can easily parse the
returned values to give you the horizontal and vertical screen space
available. Note that neither of these calls will return the actual screen
space used by the current instance of your Access application.

There are other code examples that may be useful, such as
http://www.mvps.org/access/forms/frm0042.htm. And browsing the Access Web
site may also help. I must say that I don't really understand what you mean
by "to the right of the main window, out of the way of other Access forms".
If your instance of Access which is running happens to maximized, there will
be no space "to the right of the main window". I suspect that if you are
trying to force a form to appear outside the current Access window's space
you will be out of luck - I don't think it's possible. Maybe an MVP, or
other contributor, may be able to offer further enlightment.

Again, HTH,

Rob
 
Back
Top