Your outlet for keeping abreast of what's taking place in the world of Microsoft® Office Access directly from the members of the Access Team.
Chris Downs from the Access user assistance team has just finished a nice video demo about making controls grow and shrink as the form is resized.
This looks like a nice feature, yet in my view still lacking something very important. The size of the fonts does not change when the form gets resized.
Ken Gets actually addresses this here:
http://msdn2.microsoft.com/en-us/library/bb203849.aspx (search for the word ‘scale’ in the linked article to find his relevant comment).
Almost 10 years ago, the "Developers Handbook", by Ken Gets, Paul Litwin and Mike Gilbert, already published code to resize the controls on a form as you resize the form (as the video above demonstrates). But that is only one of the added capabilities of their code. In my view the more important functionality of their code was to change the size of the form based on the users screen size preferences.
If you create a form using a particular screen size of say 1024 by 768 and then deliver your application to a user who has a different screen size setting, this form may look too small or too large on their screen. With their code, the forms will “scale as they load so they will look reasonable at almost any screen resolution”. The code iterates through all of the elements of the form and resizes them as well as their contents to fit the current resolution and also moves them proportionally. This includes all sections of the form and all of the subforms at all levels and also controls that contain other controls at all levels.
This is for me extremely complex code with many API calls and multiple internal loops (I forgot the mathematical word for a loop that calls itself). To add difficulty I quote from their book: “there’s one problem: if you resize the form so small that a subform control can’t be displayed, access destroys the control and later recreates it when you resize the form larger again…it cased us immense problems…”
I had to tweak the code because I wanted to change the subforms of a form after it was already opened and it was difficult.
So what I am getting at is that the new 2007 anchoring feature is nice but for my purposes incomplete. I hope in the next version will contain the ability to scale the forms to fit the screen size. It would make my code much more manageable and also probably make the application more stable. It would probably work much faster and more flexible too. I assume having this to be part of the internal mechanism of access will be much preferable to achieving the same thing using code.
My 2 cents
Gilad
Gilad,
Ability to use CSS based styling would be a good way to go, then make a decision of what font size/style to use based on the screen dimensions. Just changing the font size down might not be ideal - but changing to a font which is, by default, narrower on smaller screens would seem to me to be a nice touch!
I also tried the code noted above - but as you stated it was quite complex and not overly successful.
Tim
Actually... it's Ken Getz. Ken has been wonderful about sharing his Access brilliance over the years so I thought we should get his name right.
David
Thanks David for pointing to my mistake. I apologize for it.
Dear Zac, I would greatly appreciate if you, or if another moderator of this blog, will please make the necessary correction above.
Thanks
We can't edit comments without deleting the entire comment. I don't think Ken will be offended. He is actually one of the nicest guys you will ever meet.
I personally think the new Anchoring feature in Access 2007 is great and long overdue. I have also used the scaling code mentioned above but it seemed very unusual to see the font scale when you changed the size of a form (even though it was really cool to see it work). It was more like zooming in and out on your form but you never saw any additional data. All the extra API calls and code could also slow a complex form down and it was more prone to quirks.
Most applications size the controls and not the fonts and I think most people would rather see more data than the font growing. If you want a larger font you can lower your screen resolution or get a larger monitor. We develop all our forms to be no larger than 800x600 and lately have been moving some of them to 1024x768. Almost all the customers we survey are running at least 1024x768 or higher today. If anyone is still running 640x480 they are way behind the times and wouldn’t be interesting in our application anyway.
You can duplicate the anchoring feature in older versions of Access using VBA code in the OnResize event of a form by adjusting the Height, Width, Top and Left properties. This is the same technique that was used in VB6 applications before .NET shipped with built-in anchoring. Access 2007 just makes it easy to do with no code which is a welcome enhancement.
Steve