共计 995 个字符,预计需要花费 3 分钟才能阅读完成。
用户登录的具体 VBA 代码如下:
Private Sub 确定_Click()
On Error GoTo Err_确定_Click
Dim i As Integer
Dim StrTemp As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset‘判断“用户名”文本框是否为空
If Nz(Me. 密码) =“”Then
MsgBox“请输入“密码”!”, vbExclamation,“输入密码”Me![密码].SetFocus
ElseIf Nz(Me. 确认密码) =“”Then
MsgBox“请输入“确认密码”!”, vbExclamation,“输入确认密码”Me![确认密码].SetFocus
ElseIf Len(Me![ 密码]) > 20 Or Len(Me![ 确认密码]) > 20 Then
MsgBox“您输入的“密码”或“确认密码”字数太多,最多只可以输入 20 个字符!”, Me![密码] =“”Me![确认密码] =“”Me![密码].SetFocus
ElseIf Trim(Me![ 密码]) <> Trim(Me![ 确认密码]) Then
MsgBox“您输入的“密码”和“确认密码”不相同,请重新输入!”, vbExclamation,“重输密码”Me![密码] =“”Me![确认密码] =“”Me![密码].SetFocus
Else
StrTemp =“Select * From 系统用户表”‘打开“系统用户表”数据表
rs.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.MoveFirst
For i = 1 To rs.RecordCount‘判断用户输入的“密码提示”和“密码答案”是否与用户注册时设置的时候相同
If rs(“用户名”) = Me![用户名] Then
rs(“密码”) = Me![密码]
rs.Update
MsgBox“密码修改成功,你的密码是:”& rs(“密码”) &“,请您牢记密码!”, vbInformation,“修改成功”DoCmd.Close
Exit Sub
Else
rs.MoveNext
End If
Next i
End If
Set rs = Nothing
Exit_确定_Click:
Exit Sub
Err_确定_Click:
MsgBox Err.Description
Resume Exit_确定_Click
End Sub
正文完