Dynamically adjusting the size of a subform based on if the scrollbar is shown or not (1 Viewer)

jumnhy

Member
Local time
Today, 18:49
Joined
Feb 25, 2021
Messages
68
Hello all,

I have a subform which may display anywhere from 1 to n records--when n < ~15, there is no vertical scrollbar on the right side.

If I set the width of the subform control to precisely the width of the underlying form, I end up with an awkward 255 twip side-to-side horizontal scrollbar to accommodate the width of the contents.

To alleviate this, I added 255 twips/0.1771" to the width of the control. Looks great, except for the awkward empty space to the right of my rightmost column when there's no scrollbar.

Is there an easy fix for this?

1616177190905.png


And

1616177236103.png


Haven't played much with the various properties of the subform control to see if there's something that would do this automatically.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 22:49
Joined
Jan 14, 2017
Messages
18,186
The fact that you know the scrollbar is 255 twips wide suggests you may have read my article Move Forms & Controls - Mendip Data Systems.
If not I suggest you do so as the answer can be found in the example app accompanying the article.
Basically you need to determine how many records need to be displayed before the scrollbar is activated...and if that number is exceeded, modify the width accordingly
I think your understanding will be greater if you search the app/article rather than if I just give you a solution 'out of the hat'
 

jumnhy

Member
Local time
Today, 18:49
Joined
Feb 25, 2021
Messages
68
Ha, I actually hadn't seen your article, but I did get that figure from you sidelong. Much appreciate the resources--I need to spend some time reading through the treasure trove you've compiled. I much prefer to do my own legwork where I can, just need a pointer in the right direction. My knowledge of Access development is SOARING since I started working seriously, and you guys around here have been an immensely helpful part of that.

Editing to add--your article is bomb, exactly what I needed. I was half-hoping that there was an auto-resize feature somewhere inbuilt in Access, but I should probably know better by now...
 

Minty

AWF VIP
Local time
Today, 22:49
Joined
Jul 26, 2013
Messages
10,355
A really simple solution from an aesthetics perspective is to set the background of the form detail to the same colour as the background of your textbox controls. All you would see then is a small empty section rather than the other colour.
 

jumnhy

Member
Local time
Today, 18:49
Joined
Feb 25, 2021
Messages
68
Yeah, but see now I'm learning about WizHook and feeling good about my level of spanish fluency... That's a good thought, all the same.
 

Users who are viewing this thread

Top Bottom