我有一个登录系统,该系统连接到一个名为“雇员”的表。我现在需要制作一个编辑用户表单,该表单允许我编辑登录用户的用户名或密码。
我尝试使用
Me.UserName = Nz(DLookup("Username", "Employees", "Username='" & TempVars("EmployeeType2") & "'"), "")
Me.Password = Nz(DLookup("Password", "Employees", "Username='" & TempVars("EmployeeType2") & "'"), "")
但这不允许保存更改。
我该如何使tempvar 9用户名和密码以文本格式进行编辑?
这是我的登录方式的代码。
Option Compare Database
Option Explicit
Private Sub ButtonLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Employees", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.TxtUsername & "'"
If rs.NoMatch Then
Me.LblWronguser.Visible = True
Me.TxtUsername.SetFocus
Exit Sub
End If
Me.LblWronguser.Visible = False
If rs!Password <> Nz(Me.Txtpassword, "") Then
Me.LblWrongpass.Visible = True
Me.Txtpassword.SetFocus
Exit Sub
End If
Me.LblWrongpass.Visible = False
TempVars("EmployeeType") = rs!EmployeeType_ID.Value
TempVars("EmployeeType2") = rs!UserName.Value
DoCmd.OpenForm "Home"
DoCmd.Close acForm, Me.Name
End Sub
答案 0 :(得分:0)
要设置TempVar,请使用以下内容:
TempVars("EmployeeType") = Me.UserName.Value
TempVars("EmployeeType2") = Me.Password.Value