|
Option Compare Database
Private Sub Cancel_Click()
DoCmd.Quit
End Sub
Private Sub Label16_Click()
End Sub
Private Sub OK_Click()
On Error GoTo Err_OK_Click
Dim str As String
Dim rs As New ADODB.Recordset
Dim loginuserid As String
Dim lo As Boolean
lo = True
Dim nn As Integer
nn = 1
logname = Trim(Me.UserName)
pwd = Trim(Me.PassWord)
If IsNull(logname) Then
DoCmd.Beep
MsgBox ("请输入用户名称!")
Me.UserName.SetFocus
lo = False
ElseIf IsNull(pwd) Then
DoCmd.Beep
MsgBox ("请输入密码!")
Me.PassWord.SetFocus
lo = False
End If
If lo Then
str = "select * from tblSysUsers where FUserName= '" & logname & "' and FPassword='" & pwd & "'"
Set rs = GetRS(str)
If rs.EOF Then
DoCmd.Beep
MsgBox ("没有这个用户或输入密码,请重新输入!")
Me.UserName = ""
Me.PassWord = ""
Me.Text20 = ""
Me.UserName.SetFocus
Exit Sub
Else
strUserName = logname
sysuser = Trim(Me.Text20)
DoCmd.RunSQL "INSERT INTO tblSysUserslogin(FUserName,loginDate,work)VALUES( &strUserName, now(),&a) "
DoCmd.Close
MsgBox ("欢迎使用TFCL仓库管理系统!")
DoCmd.OpenForm "frmSysMain"
check = True
End If
Set rs = Nothing
Set conn = Nothing
End If
Exit_OK_Click:
Exit Sub
Err_OK_Click:
MsgBox (Err.Description)
Resume Exit_OK_Click
End Sub
Private Sub Text20_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub UserName_AfterUpdate()
On Error GoTo Err_UserName_AfterUpdate
Dim STemp As String
If IsNull(Me![UserName]) Then
UserID = Null
Else
STemp = DLookup("姓名", "userinfor", "[UserName]= '" & Me![UserName] & "'")
If IsNull(STemp) Then
UserID = Null
Me![UserName] = ""
Else
UserID = STemp
Me![Text20] = DLookup("姓名", "userinfor", "[员工编号]= '" & Me![UserName] & "'")
End If
End If
Exit_UserName_AfterUpdate:
Exit Sub
Err_UserName_AfterUpdate:
MsgBox "您“用户编号”输入错误,或者还没有注册,请检查!", vbCritical, "无此用户"
Resume Exit_UserName_AfterUpdate
End Sub
Private Sub UserName_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_UserName_BeforeUpdate
If Len(Me![UserName]) <> 5 Then
MsgBox "“用户编号”是由五位数字组成!", vbInformation, "用户编号错误"
Cancel = True
End If
Exit_UserName_BeforeUpdate:
Exit Sub
Err_UserName_BeforeUpdate:
MsgBox Err.Description
Resume Exit_UserName_BeforeUpdate
End Sub
Private Sub UserName_LostFocus()
loginuserid = Trim(Me.UserName)
If IsNull(loginuserid) Then
DoCmd.Beep
MsgBox ("请输入用户名称!")
Me.UserName.SetFocus
lo = False
End If
End Sub
Private Sub 主体_Click()
End Sub
以上执行时DoCmd.RunSQL "INSERT INTO tblSysUserslogin(FUserName,loginDate,work)VALUES( &strUserName, now(),&a) "这条语句执行时有问题? |
|