If Text1.Text = "" Then
MsgBox "工号不能为空", vbOKOnly, "提示"
Text1.SetFocus
Text1.SelStart = 0: Text1.SelLength = Len(Text1)
Else
objRs.CursorType = adOpenKeyset
objRs.LockType = adLockOptimistic
strSQL = "SELECT*FROM 管理员登录信息 WHERE 管理员工号=" & Text1 & ""
Set objRs.ActiveConnection = objCn
objRs.Open (strSQL)
If objRs.RecordCount > 0 Then 'objRs.RecordCount 的作用是记录在记录集中符合所查找信息的数据的个数
MsgBox "工号重复,请重试!", , "提示"
Text1.SetFocus
Text1.SelStart = 0: Text1.SelLength = Len(Text1)
objRs.Close
ElseIf Text2 <> Text3 Then
MsgBox "密码确认出错,请重试!", , "提示"
Text2.SetFocus
Text2.SelStart = 0: Text2.SelLength = Len(Text2)
Text3 = ""
objRs.Close
Else
objRs.AddNew
objRs.Fields("管理员工号") = Text1.Text
objRs.Fields("管理员密码") = Text2.Text
objRs.Update
objRs.Close
MsgBox "添加成功!", , "提示"
Text1 = ""
Text2 = ""
Text3 = ""
End If
End If