什么问题没发现.先说说到底什么错误.你的表格行数原来确定了吗?没有的话应该rsGrid.Rows = 行数+1或者循环中每次用AddItem不过你的程序写法不好.dim cRow as longWith rsGrid                          '显示信息内容
  cRow = 1
  While Not rs.EOF
    .TextMatrix(cRow , 0) = rs(0)
    .TextMatrix(cRows, 1) = rs(1)
    ......
   cRow = cRow + 1
   rs.MoveNext
Wend
End With
End Sub

解决方案 »

  1.   

    rs(i)里有没有NULL的值,如果有在每次用时就要判断。
    例如:If Not IsNull(rs(0)) Then .TextMatrix(.Rows - 1, 0) = rs(0)
      

  2.   

    实时错误:'91':
    对象变量或With块变量未设置上面是显示的错误信息
      

  3.   

    两点要注意:
    1)表格的列数没有指定.
    Dim rsGrid As MSFlexGrid
    With rsGrid
      .Cols = 18   '----Added ----
      .TextMatrix(0, 0) = "员工编号"
      .TextMatrix(0, 1) = "员工姓名"
      .TextMatrix(0, 2) = "员工性别"
      .TextMatrix(0, 3) = "员工籍贯"
    2)取字段值时,最好要判断其为不为空
    '.TextMatrix(.Rows - 1, 0) = rs(0)
    .TextMatrix(.Rows - 1, 0) = iif(isnull(rs(0)),"",rs(0))   '----Modified-----
      

  4.   

    同意hansong_ll(老六) 
    还有就是DIM iRow as long iCount=rs.recrdcount
    With rsGrid                          '显示信息内容
      .Rows = rs.recrdcount
      While Not rs.EOF
        .TextMatrix(iRow, 0) = rs(0)
        .TextMatrix(iRow, 1) = rs(1)
        .TextMatrix(iRow, 2) = rs(2)
        .TextMatrix(iRow, 3) = rs(3)
        .TextMatrix(iRow, 4) = rs(4)
        ...    iRow = iRow + 1
        rs.movenext
    wend
      

  5.   

    .TextMatrix(.Rows - 1, 0) = rs(0)
    改成:
    .TextMatrix(.Rows - 1, 0) = rs(0) & ""应该就行了。
      

  6.   

    对象变量或With块变量未设置
    是没有引用或没有返回记录集,