Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I add a Scroll Bar to a Form Object in VB? 2

Status
Not open for further replies.

pistolpedro

Programmer
Dec 14, 2000
2
US
I'm converting an Access 97 application to VB and some of the Access forms are larger than the maximum default height allowed in VB. How can I add a scroll bar to the actual form object in VB so that I can increase the form space that is available to me?

Thanks
 

You can place all your controls into a frame control, turn the frame's border off, and use a scrollbar to scroll the frame. The only tricky part is setting the limits on the scrollbar. Try something like this:

[tt]Option Explicit

Private Sub Form_Resize()
If Me.WindowState = vbMinimized Then
Exit Sub '<-------
End If

VScroll1.Top = 0
VScroll1.Height = Me.ScaleHeight
VScroll1.Left = Me.ScaleWidth - VScroll1.Width

If Me.ScaleHeight >= Frame1.Height Then
'disable scrollbar when scrolling not needed.
VScroll1.Enabled = False
Else
VScroll1.Enabled = True
VScroll1.Max = Frame1.Height - Me.ScaleHeight
End If
End Sub

Private Sub VScroll1_Change()
Frame1.Top = -VScroll1.Value
End Sub

Private Sub VScroll1_Scroll()
Frame1.Top = -VScroll1.Value
End Sub
[/tt]

Chip H.
 
An alternative which you might consider for the long term would be to re-do the layout of the form. One usually very easy way to do this is to group individuals on a &quot;tabcontrol&quot;.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top