Form Resizing - Setting Minimum Size w/o ActiveX

stevenblanc

Registered User.
Local time
Today, 06:55
Joined
Jun 27, 2011
Messages
103
I found one or two Active X controls that handle form resizing, but have been unable to find a way to establish resize limits using VBA.

But is there a simple way using VBA to set minimum form widths and heights?

Cheers folks,


Steven
 
Perhaps if you explain why and what you are tyring to do... Like if you want to prevent Users from resizing your forms just set the Border Style to Thin and Auto Resize to No.
 
I want to set a minimum size. I want the users to be able to resize. Maximizing is fine.

However, I do not want them able to resize a window until all there is is a two inch title bar and no body.

For example I would like to prevent the user from resizing the form narrower than 5000. Many windows forms do this, and as such I'm sure there is a way to do it.

In my other thread we came up with a solution involving an if statement and .move, though this creates a nasty effect instead of just limiting the form size.
 
Last edited:
I user baSizer module that I found online.. It works perfect.. This is the module:

Option Compare Database
'This module is used to place the form in the desired position and to specify its size.
'It is is called on the Load event of many forms.
'q_Sizer(Horizontal position,vertical position, width, height)

Public Function q_Sizer(q_Right As Integer, q_Down As Integer, q_Width As Integer, q_Height As Integer)
Const procname = "q_Sizer"
On Error GoTo q_Sizer_Error

DoCmd.MoveSize q_Right, q_Down, q_Width, q_Height
Exit Function

'................................................. ................

q_Sizer_Error:
MsgBox Error$, q_ERROR, procname
Exit Function
End Function
Now on the form load event, have something like that:
=q_Sizer(0,0,1900,10120)

Elias
 
Elias,

Thats another interesting snippet to store somewhere. Using it in Load would serve no real purpose to me other than controlling the start location.

It does almost do the job when used in Form_Resize. Except that it doesnt lock the size it just moves it. Meaning that while trying to resize you get that nasty flickering stretched image being the form bouncing back and forth between the mouse positioning and the limit.

The same which can be attained by:

If Me.InsideHeight < 5000 Then Me.InsideHeight = 5000
If Me.InsideWidth < 5000 Then Me.InsideWidth = 5000

Which also makes a peculiar pushing motion if you resize from the top or left.

It will work as an interim solution, however, as it snaps to the minimum size as soon as the user releases the mouse.

I thank you very much for that.

Still working on a perfect solution though.
 
Last edited:
Sorry, I don't have a perfect solution for your scenario...
 
The Solution that I would use in this situation would be to simply create a Form_Resize() event and insert what stevenblanc mentioned:


If Me.InsideHeight < 5000 Then Me.InsideHeight = 5000
If Me.InsideWidth < 5000 Then Me.InsideWidth = 5000

Where the '5000' indicates the minimum size you wan your form to be.

Then if a user changes the form size to smaller than '5000' it will spring back to your minimum size.
 
I have been using docmd.movesize on all my forms it works fine for me. example docmd.move (,,5000,10000)
 

Users who are viewing this thread

Back
Top Bottom