I just love the Access Developers Handbook
I recently added the ability to view unit photo's on the main menu of the Granite Fleet Manager. However if the user doesn't have photos or doesn't want to view them on the main menu then I wanted the form to be centered. I figured that the Access Developers Handbook would have the code to centre a form when it was shrunk and I was correct.
It took much longer to comb through the relevant chapter finding the code I needed than to import, implement and test the code. What an efficient use of my time! While I don't use the books much lately every time I opened them up I saved the price of the books. And I used the books lots years ago.
My understanding is that the Sybex figures there would be an insufficient market for an Access 2007 version. <sigh> However I suspect almost all the code will work quite nicely in Access 2007. I also think the authors have generally moved on to other technologies.
All I had to was import a class module from the appropriate MDB on their CD, add four lines of code and the resized form nicely centered.
At the top of the VBA code
Private mfi As FormInfo
In the load event:
Set mfi = New FormInfo
Set mfi.Form = Me
and in my subroutine which decides if I'm going to display the photos on the menu or not:
Below are the two menu forms.
The code behind the form to shrink the form is fairly simple:
Me.InsideWidth = 5.6 * 1440
The 5.6 being inches as I'm not a metric person and 1440 being the number of twips in an inch.
Now you will notice that the backup (floppy diskette image) and the stop buttons were also moved. I simply manually moved them left to suit and recorded the left position of the controls. Then I put them back on the right hand side of the form and inserted the following code.
Me.cmdBackup.Left = 4.6667 * 1440
Me.cmdQuit.Left = 5.1458 * 1440
The program randomly selects the photo from the recordset of photos that are present in the system when the main menu is opened. You can them scroll back and forth among the photos. This feature is not that useful from a technical or user viewpoint. However I figure it will look neat when the folks are looking at the demo.
(The use of the word neat may help figure out approximately my age. If you pay attention to those kinds of things that is.)
Edited 2009-05-19 to change a URL from a spammy domain to a working domain.