Solved

Access 2007: Disable Resize dynamically

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Union & Crosstab qrys 101! 6 58
Convert VBA UDF to SQl SERVER UDF 4 51
Access table not showing correct column 6 25
Troubleshooting Save_Record_Click() VBA 6 22
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…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 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