Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access Workspace size?

Posted on 2004-08-31
3
Medium Priority
?
496 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 135 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 240 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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 …

688 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