Solved

Access 2007: Disable Resize dynamically

Posted on 2012-04-06
4
664 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

911 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

17 Experts available now in Live!

Get 1:1 Help Now