Private Sub 登陆_Click()
On Error GoTo Err_登陆_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim strTmp As String
If IsNull(Me.用户) Then
MsgBox "用户不能为空,请输入用户", vbInformation, "输入用户"
Me.用户.SetFocus
ElseIf IsNull(Me.密码) Then
MsgBox "密码不能为空,请输入密码", vbInformation, "输入密码"
Me.密码.SetFocus
Else
strTmp = DLookup("用户", "用户表", "用户 = " & Forms![登陆窗体]!用户 & "'")
If IsNull(strTmp) Then
MsgBox "没有这个用户,请重新输入!", vbInformation, "出错了"
Me.用户.SetFocus
Else: strTmp = DLookup("密码", "用户表", " 用户 = " & Forms![登陆窗体]!用户 & " ' ")
If CStr(Me.密码.Text) = strTmp Then
stDocName = ChrW(20999) & ChrW(25442) & ChrW(-26782) & ChrW(26495)
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else: MsgBox "你输入的密码不正确,请重新输入!", vbCritical, , "密码错误"
Me.Requery
Me.密码.SetFocus
End If
End If
End If
Exit_登陆_Click:
Exit Sub
Err_登陆_Click:
MsgBox Err.Description
Resume Exit_登陆_Click
End Sub
其中“登陆”为按钮名称,“用户”为输入登陆用户文本框名称,“密码”为输入登陆密码文本框名称,运行后提示出错:字符串的语法错误,在查询表达式‘用户=×××"中。×××为输入的用户名