打开别人的实例时总是出现在  [实时错误“91”,对象变量或 with 块变量未设置]   的问题,应如果解决???
--------------------------------------------------------------------
程序部份原码:
Private 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 account where User_Name='" & txtUserName.Text & "'"
  '执行查询语句
 Set mrc = ExecuteSQL(txtSQL, MsgText)
  If ***mrc.EOF = True*** Then
    MsgBox "没有 " & txtUserName.Text & " 这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
    txtUserName.SetFocus
  Else
    If Trim(mrc.Fields(2)) = 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***mrc.EOF = True ***为错误出处
---------------
我已引用了"microsoft activex data object2.7 library",但问题依然

解决方案 »

  1.   

    你那句Set mrc = ExecuteSQL(txtSQL, MsgText)有问题吧,提示出什么错?
      

  2.   

    Set mrc = ExecuteSQL(txtSQL, MsgText)
    这断代吗  。是不是在上抄的。原来它使用sql的。你机器有sql可以。没有若用access的把这句改了
     set rs=new adodb.resordset
      rs.open "select * from table1",cnn,ado....
    查查以前的帖子就行了??  ok
      

  3.   

    Private Sub cmdOK_Click()
    Dim txtSQL As String
    Dim mrc As new ADODB.Recordset
    Dim MsgText As String
    UserName = ""
    If Trim(txtUserName.Text = "") Then
      MsgBox "用户名不能为空,请重新输入!", vbOKOnly + vbExclamation, "警告"
      txtUserName.SetFocus
    Else
      '查询指定用户的记录
      txtSQL = "select * from account where User_Name='" & txtUserName.Text & "'"
      '执行查询语句
     mrc.Open txtSQL, cnn
      If mrc.EOF = True Then
        MsgBox "没有 " & txtUserName.Text & " 这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
        txtUserName.SetFocus
      Else
        If Trim(mrc.Fields(2)) = 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