With DataEnvironment1.rsCommand1
.Open "select * from name where 用户名='" & Text4.Text & "' and 密码='" & Text1.Text & "'"
       
       If .EOF Then
          MsgBox "用户名或密码不正确"
          Text4.Text = ""
          Text1.Text = ""
          Text4.SetFocus
          .Close
          Else
          If Text2.Text = Text3.Text Then
          DataEnvironment1.rsCommand1![密码] = Text2.Text
          DataEnvironment1.rsCommand1.Update
          MsgBox "密码更新完毕"
          Unload Dialog
          Else
          MsgBox "新密码错误,请重新更新新密码"
           Text3.Text = ""
        
          End If
          End If
          .Close
End With出现 错误对话框“运行时错误,’3705‘,对象打开时,不允许操作

解决方案 »

  1.   

    加个判断:
    With DataEnvironment1.rsCommand1
    if .State=adStateOpen Then .Close '如果记录集对象一样打开,则将它关闭
    .Open "select * from name where 用户名='" & Text4.Text & "' and 密码='" & Text1.Text & "'"
    ......
      

  2.   

    With DataEnvironment1.rsCommand1
        If .State = adStateOpen Then .Close
        .Open "select * from name where 用户名='" & Text4.Text & "' and 密码='" & Text1.Text & "'"
        
        If .EOF Then
            MsgBox "用户名或密码不正确"
            Text4.Text = ""
            Text1.Text = ""
            Text4.SetFocus
        Else
            If Text2.Text = Text3.Text Then
                DataEnvironment1.rsCommand1![密码] = Text2.Text
                DataEnvironment1.rsCommand1.Update
                MsgBox "密码更新完毕"
                Unload Dialog
            Else
                MsgBox "新密码错误,请重新更新新密码"
                Text3.Text = ""
            
            End If
        End If
        .Close
    End With
      

  3.   

    添加 If .State = adStateOpen Then .Close运行时 .Open "select * from name where 用户名='" & Text4.Text & "' and 密码='" & Text1.Text & "'"中的from从句语法错误
    还是不好用