subform Width property - Integer (1 Viewer)

Andy74

Registered User.
Local time
Today, 05:10
Joined
May 17, 2014
Messages
117
Hello, I got an "Overflow error 6" when loading a form at some users of my application. I noticed that it comes out from a statement like this:

Code:
me.subForm.width=me.InsideWidth - 100

I noticed that some users have very large monitors, hence the value in TWIPS to be assigned exceed the limit of INTEGER data type (32767), which the datatype of the subform.width property.

Has anybody noticed this before or am I wrong in something? The only work-around I found is too put a MAX limit on the statement, but the subform will not fit nicely the parent form.

Thanks for the support.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 04:10
Joined
Feb 19, 2013
Messages
16,607
maximum size is an integer value in twips. In your case, if the subform left is >100 then you will get the error. try

me.subForm.width=me.InsideWidth - me.subForm.left-100

access will 'fill' the right side of the form with the form background colour if the window is maxed on a large monitor., Nothing you can do about that or place anything in the space.

also, rather than testing for size, just use on error resume next/on error goto 0 which also solves the problem if a user narrows the form resulting in a negative width


You should design your forms for the smallest monitor
 
Last edited:

Andy74

Registered User.
Local time
Today, 05:10
Joined
May 17, 2014
Messages
117
Hello,

thanks, but I think the error occurs because of a too big number is assigned to the Width property of the subform. If you assign a negative value to it you get the error 2100, not error 6 (overflow). For a some reason the InsideWidth property is Long datatype while Width property of subform is Integer.

Andy
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:10
Joined
May 7, 2009
Messages
19,231
can you use the InsideWidth of the subform:

Me.subform.Form.InsideWidth
 

Andy74

Registered User.
Local time
Today, 05:10
Joined
May 17, 2014
Messages
117
can you use the InsideWidth of the subform:

Me.subform.Form.InsideWidth
Thanks but this statement doesn't look like doing anything on the apperance of the subform when looking at the main form. I tried to set the property from the immediate window but it doesn't change
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:10
Joined
May 7, 2009
Messages
19,231
i totally forgot, you can use the "Horizontal Anchor" property of the subform.
set this property to Both.
 

isladogs

MVP / VIP
Local time
Today, 04:10
Joined
Jan 14, 2017
Messages
18,209
The maximum possible width of a form (or report in Access is approx 22.75 inches.
That limitation is due to the integer datatype as already mentioned
There are 1440 twips per inch and 32767/1440=22.75 to 2d.p.

You could modify your expression using IIf to allow for that limit and so prevent overflow errors

Or, if the ideas already suggested don't solve your problem, one or both of these articles on my website may be helpful:
1. Accurately Move Forms and Controls
2. Automatic Form Resizing Tutorial
Good luck
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:10
Joined
Oct 29, 2018
Messages
21,453
Hi. Also just throwing this idea out there, since I am not sure what the real intention was, but have you considered using Anchoring on the subform control?
 

Andy74

Registered User.
Local time
Today, 05:10
Joined
May 17, 2014
Messages
117
i totally forgot, you can use the "Horizontal Anchor" property of the subform.
set this property to Both.
Hello, this definitely solved the issue! I didn't know about this property. With this I can cancel all the code in the resize event! thanks
 

Andy74

Registered User.
Local time
Today, 05:10
Joined
May 17, 2014
Messages
117
Hi. Also just throwing this idea out there, since I am not sure what the real intention was, but have you considered using Anchoring on the subform control?
Well, this solved the issue!
 

Users who are viewing this thread

Top Bottom