Solved

Access 2007: Disable Resize dynamically

Posted on 2012-04-06
4
666 Views
Last Modified: 2012-05-01
Hi Experts,

On my access 2007 vba application, i have written code on the form resize event which changes the size of the controls in the form depending on the forms size when changed.

But when i make the access much smaller, i get a runtime error saying that the control is too small.

So i need a code that will not resize the form if reached for a certain size or height.

Thanks in advance.
0
Comment
Question by:baabaa_nl
4 Comments
 
LVL 9

Accepted Solution

by:
armchair_scouse earned 500 total points
ID: 37815532
In your resize code, you need to store a minimum height and width for your form, whatever it may be, and check if someone is trying to resize it below those values, then just set it to that value.  From the user's perspective, the form will shrink down to a certain size but then go no further.
0
 
LVL 75
ID: 37816616
I use this excellent product which avoids the issue, and is truly amazing in every respect.  Evolved over the years.  Check out the fully functional demo:

http://www.peterssoftware.com/ss.htm

mx
0
 

Expert Comment

by:JBHansen
ID: 37869053
This doesn't work for me. Is 2010 different than 2007? If I resize smaller than the stored minimum height, it won't actually set the form height back to the minimum until after I release the mouse button, which often is after it throws the runtime error. Any suggestions on how to cancel the resize before the runtime error gets thrown? Ignoring the error via code hasn't worked.
0
 

Author Comment

by:baabaa_nl
ID: 37875707
Hi JBHansen,

This is the code that I use on my Access 2010, and this is how I handle the error.


Private Sub Form_Resize()

	On Error GoTo Err_Form_Resize

	    ClientMain_subform.Width = Me.WindowWidth * 0.55
	    ClientMain_subform.Height = Me.WindowHeight - 1150
	    
	    imgBtoB.Left = Me.WindowWidth - 1500
	    
	    AfsprakenMain_subform.Left = ClientMain_subform.Width + 600 'Location
	    AfsprakenMain_subform.Width = (Me.WindowWidth - [Form_ClientMain subform].WindowWidth) - 1000
	    AfsprakenMain_subform.Height = Me.WindowHeight - 1150

	Exit_Form_Resize:

	Exit Sub

	Err_Form_Resize:

	    MsgBox "Form window is too small, Will resize now.  "

	Resume Exit_Form_Resize

End Sub

Open in new window


When I try to resize to a smaller size, and I get an run time error saying that the size is smaller than the main form.

So I had to write an error handler, but in that error handler I tried to keep it empty without any messagebox so that the form will resize automatically, but it didn't work, so I had to include the messagebox.

So when the form is resized smaller than the form, the an error is raised, but then handled and a message box is shown to the user as coded above and after the OK button is clicked on the messagebox, then the form resizes automatically without any application crash.

I hope this answers your question.

baabaa_nl
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question