Scrollbar appears a record early (1 Viewer)

Lkwdmntr

Registered User.
Local time
Today, 00:36
Joined
Jul 10, 2019
Messages
261
Hi Guys,

I have a subform that will increase in width when the number of records reaches 8. When it gets wider the scrollbar also appears.

This problem is that I don't actually need it to get wider until the record count is 9, but the scrollbar appears at 8. If I change the VBA to accommodate the new record size the scrollbar cuts off the last portion of the data.

Does anyone know how to have better control over the scroll bar appearing?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:36
Joined
Oct 29, 2018
Messages
14,560
Hi. Not sure, since I haven't tried it before, but have you tried setting the Scrollbars property to None and then turn it on only when you need it? Just curious...
 

isladogs

CID VIP
Local time
Today, 08:36
Joined
Jan 14, 2017
Messages
14,697
What code are you using to do this?
Though it may be irrelevant, are you aware that the property used for counting may be zero based?
 
Last edited:

Lkwdmntr

Registered User.
Local time
Today, 00:36
Joined
Jul 10, 2019
Messages
261
I don't think it would matter if it was zero-based seeing as it is going by the height of the subform. It just shows up when there are just enough records to fill the box. I don't need it until there are more records than the box can hold.

I am not familiar with how to turn on the scroll bar when needed. I would think it would be a VBA code of some sort. That would be a great option if you could tell me how to go about it.
 

isladogs

CID VIP
Local time
Today, 08:36
Joined
Jan 14, 2017
Messages
14,697
The form scrollbars property has 4 allowed values: 0 (none); 1 (horizontal only); 2 (vertical only) ; 3 (both). So for example you could use Me.scrollbars=2 when the record count reaches 9.

If you want to see an example of scrollbars (and other form properties) being manipulated in VBA, see Form1 in this example app https://www.access-programmers.co.uk/forums/showthread.php?t=303974

However as scrollbars will normally only appear if the form sizes merit that, I would suggest you are making unnecessary work for yourself. I would very slightly adjust the column widths to be wide enough when the scrollbar is visible and save that.
 

Lkwdmntr

Registered User.
Local time
Today, 00:36
Joined
Jul 10, 2019
Messages
261
I decided to just make the subform a little bigger and changing my record count. The scrollbar only shows up when I need it now. I'd rather have the extra space at the bottom instead of the scrollbar. Thanks for the help.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:36
Joined
Oct 29, 2018
Messages
14,560
Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom