?
Solved

Access 2007: Disable Resize dynamically

Posted on 2012-04-06
4
Medium Priority
?
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Accepted Solution

by:
armchair_scouse earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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