Solved Why do scroll bars appear for no reason? (1 Viewer)

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
I'm sure you have seen this before, but this is driving me crazy. In a subform, I have just two records that are fully visible on the screen and a scrollbar appears on the right of the form! There is absolutely no reason to have a scroll bar appear until the form fills up with more records then will fit inside the form.😕 Of course the answer is to keep adjusting the form until the scrollbar goes away. This is fine if you only want two records to show in the subform but what if you want three or four? That's when the scroll wheel will show two records again with lots of space for another record but if the scrollbar is used, it forces a scrollbar to appear and it gets lock in the up position showing only one record. Why does a scroll bar even appear in the first place when both records are fully visible on the screen??? This is so annoying.

In my situation, I have fat records that take up a lot of space so only two records fit in a subform with a functioning scrollbar. If the subform height is increased to show three records the scrollbar problem becomes worse.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:08
Joined
May 7, 2009
Messages
19,169
you can use the subform's current event to show/hide the vertical scrollbar:

Private Sub Form_Current()
Me.ScrollBars = IIf(Me.Recordset.RecordCount > 2, 2, 0)
End Sub
 

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
That's actually a very good idea Arnel.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:08
Joined
May 7, 2009
Messages
19,169
good luck with your coding.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:08
Joined
Feb 19, 2002
Messages
42,971
The reason the scroll bar appears is not random. Access is a lot of things but "random" is not one of them.

Play with sizing the form until the scroll bar disappears. As long as you need scrollbars, Access allows room for them at the right and/or bottom of the form so you might see a gray stripe where the scroll bar goes.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 04:08
Joined
Jan 20, 2009
Messages
12,849
Access is a lot of things but "random" is not one of them.

I think "random" could apply to the appearance of the control tool tips (unless they have fixed it since I last looked at them many years ago).
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:08
Joined
Feb 19, 2002
Messages
42,971
Actually, they show up when Access determines that you need to see them. As I said, resizing the form to be slightly larger will change Access' opinion of when it needs to show them.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:08
Joined
Feb 19, 2013
Messages
16,553
Why does a scroll bar even appear in the first place when both records are fully visible on the screen
is the form set to not allow additions? if not then there could be a third 'new record' row
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:08
Joined
Feb 19, 2002
Messages
42,971
You do have the ability to turn off the scroll bars if they are NEVER needed.
 

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
is the form set to not allow additions? if not then there could be a third 'new record' row
CJ, that is correct. The exact situation was a form that has the AllowAdditions set to False until someone adds a new record via ADD button. And now that you bring that up, it does make sense why Access turns the scroll bar on now since it probably assumes that AllowAdditions is True. Thank you for bringing that up CJ.

And Pat, yes I did just that CONDITIONALLY and am quite happy with the results now.
 

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
I had to mark this as unsolved because of another error that is generated by this line of code when there are no records in the subform. That's a big problem because there will be many occasions when the subform will not have any records in them. On every new job, there won't be any records! There is another thread I created about that error but in short, it's a "No Current Record" error.

Code:
Private Sub Form_Current()
    Me.ScrollBars = IIf(Me.Recordset.RecordCount > 2, 2, 0)
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:08
Joined
May 7, 2009
Messages
19,169
just ignore the error:
Code:
Private Sub Form_Current()
On Error Goto NoScrollBar
    Me.ScrollBars = IIf(Me.Recordset.RecordCount > 2, 2, 0)
    Exit Sub
NoScrollBar:
    Me.ScrollBars = 0
End Sub
 

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
I would love to just ignore that error, but this particular error is un-trappable if that is even a word. I have not found a way to trap "No Current Record" error. That is a crazy error.

At this point, Pats idea of just completely turning off the scrollbars is the only one that works. At least until I can find a better solution.
 
Last edited:

Mike Krailo

Well-known member
Local time
Today, 13:08
Joined
Mar 28, 2020
Messages
1,030
This is all cleared up now in the other thread about "No Current Record". Thanks to all who helped with this frustrating problem.
 

Users who are viewing this thread

Top Bottom