|
'看看这样行了吗?我调整了判断语句的位置,其它的没有变化。
'再者你GetRs函数中没有代码,故不能测试
Private Sub cmdok_Click()
On Error GoTo err_cmdok_click
Dim Rs As ADODB.Recordset
Dim str As String
Dim i As Integer
Dim username As String
Dim password As String
username = Trim(combo7.Value)
password = Trim(text2.Value)
Set Rs = New ADODB.Recordset
i = i + 1
If IsNull(username) Then
DoCmd.Beep
MsgBox ("请选择用户名!")
Exit Sub
End If
If IsNull(password) Then
DoCmd.Beep
MsgBox ("请输入密码!")
Exit Sub
End If
str = "select * from 登陆表 where 登陆表.部门名称='" & username & "'and 登陆表.密码='" & password & "'"
Set Rs = GetRs(str)
If Rs.EOF Then
DoCmd.Beep
If i < 3 Then
MsgBox ("请重新输入! ")
'combo7 = ""
text2 = ""
text2.SetFocus
Else
MsgBox ("密码错误!对不起,您无权进入本系统!")
End If
Exit Sub
Else
' DoCmd.Close
Me![cmdok].SetFocus
MsgBox ("欢迎使用工时统计系统!")
check = True
DoCmd.OpenForm "窗体1"
'DoCmd.OpenForm "工时输入窗体", , , "[部门] = 'combo7'"
End If
Set Rs = Nothing
Set conn = Nothing
exit_cmdok_click:
Exit Sub
err_cmdok_click:
MsgBox Err.Description
Resume exit_cmdok_click
End Sub
|
|