Place an MSHFlexgrid and a vScroll bar on a form. Paste the following code into the form load event...
Dim Rs As ADODB.Recordset
Dim Cn As ADODB.Connection
Set Cn = New ADODB.Connection
Cn.CursorLocation = adUseClient
VScroll1.Enabled
VScroll1.Visible = False
Cn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=D:\NorthWind.mdb;"
Set Rs = New ADODB.Recordset
Rs.Open "Select top 11 CustomerID from Customers", Cn, adOpenStatic, adLockOptimistic
Set MSHFlexGrid1.DataSource = Rs
Dim Total As Integer
For x = 0 To MSHFlexGrid1.Rows - 1
Total = Total + MSHFlexGrid1.RowHeight(x)
Next x
If Total < MSHFlexGrid1.Height Then VScroll1.Visible = True
This code assumes no HScrollbar. With an HScrollbarr you will have to make similar calculations using the Column Widths rather than RowHeight.
Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com
Scot Rose, MCSD
Microsoft Visual Basic Developer Support
This posting is provided AS IS, with no warranties, and confers no rights.