Solved

MS Access Workspace size?

Posted on 2004-08-31
3
471 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now