The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Resizing controls in Access

Hello everybody.
I just relized that the width property of MS Access forms changes after a resize only in design mode. That is, if you resize a running form, whidt and height stay the same.

This means that I can not resize or reposition controls inside the form after a maximize or a resize.
It is hard to believe, maybe I'm missing something, does anybody has some hints?

many thanks.
Sevenoaks Send private email
Wednesday, November 08, 2006
 
 
You might try using the InsideHeight and InsideWidth properties of the Form object.
Tim Send private email
Wednesday, November 08, 2006
 
 
Hi Sevenoaks,

Resizing an Access form and its controls can be done with a bit of smoke and mirrors.
Getz et al; discuss a technique in their book Access Developer's Handbook (sold by the kilo).

There's a sample of the Class you can download at the book's website:

http://www.developershandbook.com/downloads.htm

Enjoy!
Marcus from Mellbourne
Wednesday, November 08, 2006
 
 
Thank you Marcus.

The resource you pointed me to is really interesting. It deserves and deserves deepening.

Unluckyly I'd like to resize controls as the user resizes the form, not to resize the form according to screen resolution.
Sevenoaks Send private email
Thursday, November 09, 2006
 
 
The answer does indeed lie with the InsideWidth and InsideHeight properties of the form.  Here is an example of how to do it.

Just create new form and plonk a command button called Command1 on it.

I recommend that you also disable the following properties of the form to remove some of the clutter (but this is not mandatory):

* Navigation Buttons
* Record Selectors
* Dividing Lines
* Scrollbars (set it to Neither)

Having done that, paste the following code into your form's resize event handler:

Private Sub Form_Resize()

Const BORDER_SIZE_TWIPS As Long = 200
   
    Me.Painting = False
       
    Me.Command1.Width = Me.InsideWidth - (2 * BORDER_SIZE_TWIPS)
    Me.Command1.Height = Me.InsideHeight - (2 * BORDER_SIZE_TWIPS)
    Me.Command1.Left = BORDER_SIZE_TWIPS
    Me.Command1.Top = BORDER_SIZE_TWIPS
         
    Me.Painting = True
   
End Sub

That should work quite nicely.  It is a simple example, but can be easily extended to cover more controls and anchoring options.

A few notes:
* BORDER_SIZE_TWIPS is just my own constant - it has no special MS Access significance.  It just represents the distance between the internal edge of the form and the edge of the control.

* Setting Me.Painting = False prevents intermediate steps in the resizing of the control from being displayed.  You'll notice I set it back to True once I'm done.

Cheers,
Chris.
Chris B
Thursday, November 09, 2006
 
 
GREAT!

Many thanks Chris! It was exactly what I was looking for.

I owe you a favor.
Sevenoaks Send private email
Thursday, November 09, 2006
 
 
See <http://www.jamiessoftware.tk/articles/resolution.html>

I've used the ADHResize.MDE on a couple of projects and it works pretty well. Lets you resize automatically or as a form is sized.
Former COBOL Programmer
Thursday, November 09, 2006
 
 
Last I looked at the code in the Access Developer's Handbook, it didn't handle tab controls. But that was back in the last ice age. Has their code managed that trick yet? Or any of the other code?
JeremyNYC Send private email
Wednesday, November 15, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz