Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2005, 06:48 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically resizing forms

I have written an Access2000 application for a customer. The customer has many computers that need replacing as they are well past their 'sell-by' date, but if they aren't broke, why fix them? The problem I have is that the old computers run on a resolution of 800x600, the new ones at 1024x768, and their very latest ones with 19" flat panel monitors at much higher resolutions. Is there any code that can be included in a form's OnOpen or OnResize event that will automatically resize the form. There is a simple piece of code in the Microsoft Knowledge base (it used to be article Q210106) that will detect the screen resolution, but how do I use it once I have found it?

Thanks

 
Old May 6th, 2005, 07:19 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

The DoCmd.MoveSize operation will move and resize the active form.

Of course you will have to deal with determining how much of the screen the Access application itself is using. But if you maximize the Access window, you can do your calculations based on screen resolution.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old May 6th, 2005, 07:59 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I think. However, I thought that DoCmd.MoveSize only moved the boundaries of the visible window (and its position), but left the underlying form with its controls and whatever at the same size, allowing the user to see more (or less) of the form by using scroll bars. What I wish to do is to phyiscally alter the magnifictaion (for want of a better word) of the form so that whatever the user's resolution, screen or window size all of the form is visible .

I will try it.


 
Old May 7th, 2005, 07:34 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ah ha! You didn't say that you also wanted to resize the controls!

You can do what you wish. But it is a very manual process.

When you say "magnification", that could imply that as the controls get larger, you want the lettering within the control to increase in size also. If that's what you want, you're in for a lot of setup and testing.

However, if you just want to resize the controls, for example to allow more lines to display in a subform for a larger screen, it isn't simple but it can be done.

There are many ways to approach it. But one of the keys you will need is:

Code:
Dim ctl As Control

For Each ctl In Me.Controls
    ' resize the control
    ctl.Height = 200
    ctl.Width = 400
Next ctl
Of course you will have to figure out how to determine what 200 and 400 should really be.

You might even want to set ctl.Top and ctl.Left.

An easy way to do this is simply pick the controls that will change size and hardcode the settings without looping through all controls.

Another way is to start with designing the form for the smaller resolution screen and multiple by some percentage.

Another way is to build for the smaller resolution then use the Tag property to control the resize for the larger screen. Code something like this:

Code:
Dim ctl As Control

For Each ctl In Me.Controls
    ' resize the control
    if ctl.Tag <> "" then
        ctl.Top = split(ctl.Tag,";")(0)
        ctl.Left = split(ctl.Tag,";")(1)
        ctl.Width = split(ctl.Tag,";")(2)
        ctl.Height = split(ctl.tag,";")(3)
    end if
Next ctl
Then in the tag value for each control specify: Top;Left;Width;Height

Regardless of how you choose to do it, you will have to manually control the settings for each control within the form. Unfortunately, there is no magic within Access to do this for you.

After you have done the initial sizing for the screen resolution, you can use the For .. Next loop to proportionally resize the controls in the OnResize Event procedure. This is still a very tricky proposition.

BTW, my choice has been to pick controls that are worth resizing, e.g. a subform that displays multiple records. Call me lazy. But I figure I spend enough time building the rest of the application... the users can bloody well invest in hardware that is compatible with the way I build it. Hardware is cheap. My time is invaluable!

Oh, and I know a guy that builds his forms such that he gets the benefits of a larger screen without writing any code to resize. He sets up the form as a continuous form and uses the header and footer for static size fields. The scroll region of the form grows and shrinks automatically. It looks a little funky because of the scroll bar. But it allows him to utilize is time for more than just asthetics.

Good luck.
 
Old May 11th, 2005, 04:24 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your assistance in this, but if anyone else is interested, another customer has loaned me a copy of Access 2000 Developer's Handbook (Volume 1: Desktop Edition) [ISBN 0-7821-2370-8] in which there is a whole section of a chapter (Chapter 8) which covers just this subject.

However, on reading it I think I will tell the customer to buy bigger screens!

Cheers!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing Forms Apocolypse2005 Beginning VB 6 6 April 20th, 2007 05:43 PM
Dynamically load new forms into Frames MichaelS Classic ASP Professional 0 July 11th, 2006 02:59 PM
Is there a way to call forms dynamically reyboy Pro VB 6 11 July 7th, 2006 09:53 PM
Loading forms dynamically bmains C# 2005 1 November 30th, 2005 03:53 PM
Save Dynamically created forms DaDeViL Access VBA 2 August 17th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.