Anyone had any when updating a msflexgrid (which includes clearing then re-populating).

I keep having rows pop out of nowhere, and when I click on my re-populate query, they subquentially go from one less row to the correct number...

In general I'm having all sorts of bugs, prob which are attributed to my code,

Currently here is my main code that writes to the flexgrid.

VB Code:
  1. Private Function WriteShow(pShow As String)
  2.     Debug.Print "Writing Show"
  3.     On Error GoTo Error
  4.    
  5.     If Selection = Show_Name Then
  6.         'TreeView.SelectedItem.Next
  7.         'TreeView.SelectedItem.Next
  8.         'TreeView.SelectedItem.Next
  9.         Selection = Show_Name & ".Rundown"
  10.     End If
  11.    
  12.     FlexGridDone = False
  13.    
  14.    
  15.    
  16.    
  17.     Dim Counter As Integer
  18.     Dim Counter2 As Integer 'For Refresing of FlexGrid
  19.     Dim Total As Integer
  20.     'Remove All Items Cept The First Top Item!
  21.    
  22.     Counter2 = 2
  23.    
  24.     Total = MSFlexGrid1.Rows
  25.    
  26.     'Remove all items?
  27.     If Total >= 1 Then
  28.         Do Until Counter2 = MSFlexGrid1.Rows
  29.             MSFlexGrid1.RemoveItem (Counter2)
  30.             Counter2 = Counter2 + 1
  31.         Loop
  32.     End If
  33.    
  34.     'Act Normal
  35.     cn.Open
  36.     SQL = "SELECT * FROM `Rundown` WHERE `Show` = '" & Show_Name & "' ORDER BY `Pos` ASC"
  37.    
  38.     rs.Open SQL, cn, adOpenForwardOnly, adLockOptimistic
  39.     Counter2 = 0
  40.    
  41.     'MSFlexGrid1.RemoveItem
  42.     Counter = 1
  43.     With rs
  44.         Do Until rs.EOF = True
  45.             MSFlexGrid1.AddItem ("")
  46.             'Fill In the Col. Data.
  47.                 MSFlexGrid1.TextMatrix(Counter, 2) = !Tal
  48.                 MSFlexGrid1.TextMatrix(Counter, 3) = !Slug
  49.                 MSFlexGrid1.TextMatrix(Counter, 4) = !Format
  50.                 MSFlexGrid1.TextMatrix(Counter, 5) = !Graphics
  51.                 MSFlexGrid1.TextMatrix(Counter, 6) = !Status
  52.                 MSFlexGrid1.TextMatrix(Counter, 7) = !Tape
  53.                 MSFlexGrid1.TextMatrix(Counter, 8) = !SOT
  54.                 MSFlexGrid1.TextMatrix(Counter, 9) = !Read
  55.                 MSFlexGrid1.TextMatrix(Counter, 13) = !autonumber
  56.                 '.TextMatrix(Counter, 2) =
  57.             'Go To New Row
  58.             'Fill First Col With Data
  59.             Counter = Counter + 1
  60.             .MoveNext
  61.         Loop
  62.        
  63.     End With
  64.    
  65.    
  66.     Dim Total_Results As Integer
  67.     Total_Results = Counter - 1
  68.     rs.Close
  69.     cn.Close
  70.    
  71.    
  72.     'Fix for wierd cell bug
  73.     MSFlexGrid1.Row = 1
  74.     MSFlexGrid1.Col = 1
  75.     MSFlexGrid1.CellBackColor = RGB(255, 255, 255)
  76.    
  77.    
  78.     'Possibly Fix another bad FlexGrid Bug?
  79.     If MSFlexGrid1.Rows >= Total_Results Then
  80.         MSFlexGrid1.RemoveItem (MSFlexGrid1.Rows)
  81.     End If
  82.    
  83.     If Not MSFlexGrid1.Rows = Total_Results Then
  84.         WriteShow (Show_Name)
  85.         MSFlexGrid1.Redraw = True
  86.         MSFlexGrid1.Refresh
  87.     End If
  88.    
  89.     'Fix another flexgrid bug we've developed!
  90.     'Remove all rows w/o Identifer
  91.     'Dim Counter3 As Integer
  92.     'Counter3 = 2
  93.     'Do Until Counter3 = MSFlexGrid1.Cols
  94.     '    If MSFlexGrid1.TextMatrix(Counter3, 13) = "" Then
  95.     ''        MSFlexGrid1.RemoveItem (MSFlexGrid1.Row)
  96.      '   End If
  97.     ' '   Counter3 = Counter3 + 1
  98.     'Loop
  99.    
  100.     FlexGridDone = True
  101.     FillGrid = True
  102.     MSFlexGrid1.Redraw = True
  103.     MSFlexGrid1.Refresh
  104.    
  105. Error:
  106.     If Err.Number = 30002 Then
  107.         MSFlexGrid1.Redraw = True
  108.         MSFlexGrid1.Refresh
  109.         FlexGridDone = True
  110.         FillGrid = True
  111.     End If
  112.         MSFlexGrid1.Redraw = True
  113.         MSFlexGrid1.Refresh
  114.         FlexGridDone = True
  115.         FillGrid = True
  116.         'Debug.Print "Another FlexGrid Error " & Err.Number & " " & Err.Description
  117. End Function

Sorry I know it's crappy. It would be more suitable to zip up the code and ship it off for help. However I'm referencing a database and it may not show just correctly. However I may let someone here on these forums to VNC in if they would like... that's a worst case senario though... HOpefully someone can find something in this block of code and help me understand why my code doesn't work... I know it must be my code and not FlexGrid!