Solved

MS Access Workspace size?

Posted on 2004-08-31
3
488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

734 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