Turn scroll bar on based on record count

M

mwp

Hello,

I have a subform that runs sql to pull back account names based on an account
number. I have limited space so I want to turn the vertical scroll bar for
the subform on if the record count excedes 5 account names.

Can someone provide the logic to handle this? Thanks in advance.
 
M

Marshall Barton

mwp said:
I have a subform that runs sql to pull back account names based on an account
number. I have limited space so I want to turn the vertical scroll bar for
the subform on if the record count excedes 5 account names.


Use the Load event:

With Me.RecordsetClone
.MoveLast
If .RecordCount <= 5 Then
Me.ScrollBars = 0 'none, 1 for Hscroll only
Else
Me.ScrollBars = 2 'Vscroll, 3 for both
End If
End With
 
D

Dale Fye

in the main forms current event, you might put something like:

me.subControlName.Form.Scrollbars =
IIF(me.subControlName.form.recordsetclone.recordcount <= 5, 0, 2)

Then, put something similar in the subforms after insert event, so that it
checks each time you add a new record.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
M

mwp

It works great when I first enter an account that has more than 5 account
names.

When I go back and enter another account that does not have 5 account names
it leaves a grey solid bar where the scroll used to be. How can I reset it
so this bar goes away? Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top