|
Private Sub OK_Click()
On Error GoTo Err_OK_Click
Dim str As String
Dim rs As New ADODB.Recordset
logname = Trim(Txt.UserName)
pwd = Trim(Txt.Password)
If IsNull(logname) Then
DoCmd.Beep
MsgBox ("请输入用户姓名!")
ElseIf IsNull(psd) Then
DoCmd.Beep
MsgBox ("请输入用户密码!")
Else
str = "select * from Admin where UserName='" & logname & "' and Password='" & pwd & "'"
rs.Open str, CurrentProject.Connection
If rs.EOF Then
DoCmd.Beep
MsgBox ("没有这个用户,请重新输入!")
Txt.UserName = ""
Txt.Password = ""
Txt.UserName.SetFocus
Exit Sub
Else
DoCmd.Close
MsgBox ("欢迎使用客户关系数据库!")
check = True '设置登陆标志
DoCmd.OpenForm ("主窗体")
End If
End If
Set rs = Nothing
Set conn = Nothing
Exit_OK_Click:
Exit Sub
Err_OK_Click:
MsgBox (Err.Description)
Resume Exit_OK_Click
End Sub
红色的地方以前是Me.但运行总是错误,后来上网查询,有人说改成txt.因为是文本框。可这改完之后,运行就提示“要求对象”。现在要怎么改呢?
我不太会代码,这也是看书上写的,各位好心人帮帮我吧,万分感谢先!! |
|