我是新手 从买的书的光盘里考了一个 VB 开发 使用SQL SERVER  通过ODBC建立连接的一个管理系统
但是运行程序 在登陆框输入正确的用户名密码后 出现 "实时错误91 对象变量或WITH块变量未设置"
实在不知道该怎么解决才能让程序正常运行 
求助高手指点 谢谢  小弟急用  再次谢谢

解决方案 »

  1.   

    源码如下:Option Explicit
    Public OK As Boolean
    Dim miCount As IntegerPrivate Sub Form_Load()
      OK = False
      miCount = 0
    End SubPrivate Sub cmdOK_Click()
      Dim txtSQL As String
      Dim mrc As ADODB.Recordset
      Dim Msgtext As String
      UserName = ""
      If Trim(txtUserName.Text = "") Then
        MsgBox "用户名不得空缺,请重新输入!", vbOKOnly + vbExclamation, "警告"
        txtUserName.SetFocus
      Else
        txtSQL = "select * from user_Info where user_ID='" & txtUserName.Text & "'"
        Set mrc = executeSQL(txtSQL, Msgtext)
        If mrc.EOF = True Then
         MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
         txtUserName.SetFocus
       Else
         If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
           OK = True
           mrc.Close
           Me.Hide
           UserName = Trim(txtUserName.Text)
         Else
           MsgBox "输入密码不对,请重新输入!", vbOKOnly + vbExclamation, "警告"
           txtPassword.SetFocus
           txtPassword.Text = ""
         End If
       End If
     End If
     miCount = miCount + 1
     If miCount = 3 Then
      Me.Hide
      End If
      Exit Sub
     End Sub
      

  2.   

    系统指向需要调试 为  If mrc.EOF = True Then  这一行
      

  3.   

    这说明Set mrc = executeSQL(txtSQL, Msgtext)返回了Nothing
      

  4.   

    呵呵,把光标放到executeSQL这里,然后点击右键,选择“定义”,就可以跳转到executeSQL的代码里去了,检查一下它的代码