该成这样:If Trim(txtusername.Text = "") Then
    MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
    txtusername.SetFocus
Else
Txtsql = "select * from user_info where user_info.user_id= trim(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

解决方案 »

  1.   

    将Dim mrc As ADODB.Recordset改为
    Dim mrc As new ADODB.Recordset;
    If Trim(txtusername.Text = "") Then
    改为:
    If Trim(txtusername.Text) = "" Then
      

  2.   

    改过之后又出现下面提示:
    the operation requested by the application is not allowed if the objection is closed
      

  3.   

    "实时错误'91'""对象变量或WITH块变量未设置"不知是什么意思??此错误一般是代码结构不完整,也许是IF语句没对应
      

  4.   

    你的SQL语句不对。
    "select * from user_info where user_info.user_id='" & trim(txtusername.Text) & "'"
      

  5.   

    可以照下面的方法改一下就可以了:
    dim rs as new ADODB.Recordset
    With rs
    .ActiveConnection = "DRIVER=SQL Server;" & "SERVER=(local);" & "UID=sa;" & "WSID=SOFT;" & "DATABASE=dlxt;" & "LANGUAGE=us_english"
    .Source = "insert 电力能耗表(数量,日期,记录人) values(" & sl & ",'" & rq & "','" & jlr & "')"
    .Open
    End With