Solved

MS Access Workspace size?

Posted on 2004-08-31
3
458 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

771 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

11 Experts available now in Live!

Get 1:1 Help Now