sql = "select book.bookid,bname,borrowtime from book,borrowmessege where book.bookid=borrowmessege.bookid and borrowmessege.passname='" & passname & "'" Set rs = getRS(sql)         '返回一个记录集  With Me.MSFlexGrid1
       .TextMatrix(0, 0) = "id"
       .TextMatrix(0, 1) = "书名"
       .TextMatrix(0, 2) = "借阅日期"
     
  End With         ' 运行到这里没有错,再往下就有错,错误类型:无错误提示,怪.
       On Error GoTo err_description
         
           With Me.MSFlexGrid1
               .Rows = 1
               If rs.RecordCount <> 0 Then
                 While Not rs.EOF
                   .Rows = .Rows + 1
                   .TextMatrix(.Rows - 1, 0) = rs(0)
                   .TextMatrix(.Rows - 1, 1) = rs(1)
                   .TextMatrix(.Rows - 1, 2) = rs(2)
                   rs.MoveNext
                Wend
               End If
           End With
err_description:
     MsgBox "错误提示:" & Err.Description, vbOKOnly, "sorry,发生错误"
     Resume err_exit
err_exit:
     Set rs = NothingExit Sub
怎么会这样,怪.
救我

解决方案 »

  1.   

    什么错误提示!
    还有你至少要把值付给MSFlexGrid1
    set MSFlexGrid1.datasource=rs
      

  2.   


    Private Sub Form_Load()  Dim rs As New ADODB.Recordset  sql = "select username,department,grade,class,age,lasttime ,sex from dbusermessege where passname='" & passname & "'"  Set rs = getRS(sql)  If rs.EOF = False Then
         If IsNull(rs(0)) = False Then lblusername.Caption = rs(0)
         If IsNull(rs(1)) = False Then lbldepartment.Caption = rs(1)
         If IsNull(rs(2)) = False Then lblgrade.Caption = rs(2)
         If IsNull(rs(5)) = False Then lbllasttime.Caption = rs(5)
         If IsNull(rs(3)) = False Then lblclass.Caption = rs(3)
         If IsNull(rs(4)) = False Then lblage.Caption = rs(4)
         If IsNull(rs(6)) = False Then lblsex.Caption = rs(6)
         rs.Close
     End If
     sql = "select book.bookid,bname,borrowtime from book,borrowmessege where book.bookid=borrowmessege.bookid and borrowmessege.passname='" & passname & "'" Set rs = getRS(sql)
     
      If rs.RecordCount <> 0 Then            Set MSFlexGrid1.DataSource = rs          '这里出现错误,
                                             对象变量或 With 块变量没有设置(错误 91)
                                                   真是奇怪.
                                                我该怎么该啊  With Me.MSFlexGrid1
       
           .TextMatrix(0, 0) = "id"
           .TextMatrix(0, 1) = "书名"
           .TextMatrix(0, 2) = "借阅日期"
         
      End With    With Me.MSFlexGrid1
           .Rows = 1
              While Not rs.EOF
               .Rows = .Rows + 1
               .TextMatrix(.Rows - 1, 0) = rs(0)
               .TextMatrix(.Rows - 1, 1) = rs(1)
               .TextMatrix(.Rows - 1, 2) = rs(2)
               rs.MoveNext
              Wend
                      
                   
          End With
      End If
      
    End Sub