Solved

Access 2007: Disable Resize dynamically

Posted on 2012-04-06
4
661 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
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now