Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/253211

From BetaArchive Wiki

Article ID: 253211

Article Last Modified on 10/15/2002


  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition

This article was previously published under Q253211


Using very large recordsets with the Microsoft DataGrid Control 6.0 or the Microsoft Hierarchical FlexGrid Control 6.0 can cause problems when scrolling the grid. When the user drags the thumbtrack to the bottom of the vertical scrollbar, the thumbtrack might jump back to the top. This happens whenever the top row of the grid would have been greater than 65,535.


Limit the recordset to fewer than 65,536 records. While the grid can display more rows, you cannot use the thumbtrack to scroll past this number.

This bug does not show up in the OLEDB version of the APEX True DBGrid.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.


Steps to Reproduce Behavior

  1. Create a new Standard EXE in Microsoft Visual Basic. Form1 is created by default.
  2. On the Project menu, select References, and add Microsoft ActiveX Data Objects 2.x Library.
  3. On the Project menu, select Components, and add the following:

    Microsoft DataGrid Control 6.0 (OLEDB)
    Microsoft Hierarchical FlexGrid Control 6.0 SP3 (OLEDB)

  4. Place two Command buttons, a DataGrid, and a MSHFlexGrid on Form1.
  5. Place the following code into Form1:

    Option Explicit
    Dim rs As ADODB.Recordset
    Private Sub Command1_Click()
       Set rs = New ADODB.Recordset
       With rs
          .Fields.Append "Record Number", adBigInt
          Dim x As Long
          For x = 1 To 65535
             ![Record Number] = x
          Next x
       End With
       Set DataGrid1.DataSource = rs
       Set MSHFlexGrid1.DataSource = rs
       Command2.Enabled = True
    End Sub
    Private Sub Command2_Click()
       Dim x As Long
       With rs
          For x = 1 To 5
             ![Record Number] = .RecordCount
          Next x
       End With
       Set MSHFlexGrid1.DataSource = rs
    End Sub
    Private Sub Form_Load()
       Command1.Caption = "Add 64K"
       Command2.Caption = "Add 5"
       Command2.Enabled = False
    End Sub
  6. Run the code and click Add 64K. Drag the thumbtrack to the bottom of the vertical scrollbar on each grid, and note that the grids scroll properly.
  7. Click the Add 5 Command button until you have enough records to scroll past record number 65,537. Drag the thumbtrack to the bottom of the vertical scrollbar on each grid, and note that the thumbtrack jumps to the top of the recordset when released at the bottom.


NOTE: In Visual Basic 6.0 versions prior to SP3, the Hierarchical Flex Grid was limited to 2048 rows. See the following Knowledge Base article for more information:

194653 FIX: MSHFLexGrid Does Not Display More Than 2048 Rows

Keywords: kbbug kbdatabinding kbdatabase kbprb kbmdacnosweep KB253211