Solved

MS Access Workspace size?

Posted on 2004-08-31
3
481 Views
Last Modified: 2012-08-14
Hello,

I have a form that I'd like to appear "Maximized", however, if I maximize the form, all concurrent forms will be maximized aswell, which I'm not interested in. Do you know any VBA Procedures to determine the width and height of the current "workspace" in Access so I can make custom procedures to resize the form when it's loaded, based on the size of the users Access application / menubars etc.

Thanks,
 - Rasmus.
0
Comment
Question by:Amokoma
3 Comments
 
LVL 12

Assisted Solution

by:fulscher
fulscher earned 45 total points
ID: 11939841
Paste the following code into a module (must be a module, will not work if you paste it into a form code):

<code>
Option Compare Database
Option Explicit

Type RECT_Type
   left As Long
   top As Long
   right As Long
   bottom As Long
End Type

Declare Function apiGetClientRect Lib "user32" Alias _
   "GetClientRect" (ByVal hWnd As Long, lpRect As RECT_Type) As Long
</code>

In your form code, do the following:

<code>
Option Compare Database
Option Explicit

Private Sub Form_Load()
    Dim r As RECT_Type

    Call apiGetClientRect(Application.hWndAccessApp, r)
    MsgBox "Height: " & r.bottom & ", width: " & r.right
End Sub
</code>

The r.bottom and r.right members should contain the dimensions of the usable workspace of Access. When I tried it, it looked about right.

Jan
0
 

Accepted Solution

by:
ksiv earned 80 total points
ID: 11939877
Private Sub Form_Current()
Dim FormWidth, FormHeight As Integer
   DoCmd.RunCommand acCmdAppMaximize
   DoCmd.Maximize
   FormWidth = Me.WindowWidth
   FormHeight = Me.WindowHeight
   DoCmd.Restore
   DoCmd.MoveSize 0, 0, FormWidth, FormHeight
End Sub

the preceding code will always make the form "maximized"
this line "DoCmd.RunCommand acCmdAppMaximize" is to make the Access Window maximized
the line "DoCmd.Maximize" is to make the current open form maximized

hopes it's helpful to you
0
 

Author Comment

by:Amokoma
ID: 11940341
To fulcher:

Well, that seems to be getting the total size of the application window, not the workspace area (excluding top-bar / menubars - which may vary in height)?

To ksiv:

Hehe, atleast if putting it in Form_Current() on a Continuous Form will make the window jump around alot when maximizing the whole time. Although it seems the best solution atm (Have changed the code so it'll only resize one.)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question