데이터베이스에 대한 사용자 액세스를 제어하기 위해 사용할 로그인 양식이 있습니다. 사용자 비밀번호 = "비밀번호"로 초기화하고 처음 로그인 할 때 비밀번호를 변경하라는 메시지를 표시합니다. 내 사용자 자격 증명을 저장하는 사용자 테이블을 업데이트하는 데 어려움을 겪고 있습니다.액세스 로그인 양식 암호 변경 및 업데이트 : SQL/VBA
일반 로그인 VBA는 frm_Login과 관련된 : 암호 (사용자 요청뿐만 아니라 변경 포함하려면이에 따라 확장 할 계획) "비밀번호"인 경우
Option Compare Database
Option Explicit
Private Sub btnLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("X_tblUsers", 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("UserName").Value = Me.txtUserName.Value
If Me.txtPassword = "password" Then
DoCmd.OpenForm "frm_PassChange"
End If
If rs!UserType = 3 Then
Dim prop As Property
On Error GoTo SetProperty
Set prop = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False)
CurrentDb.Properties.Append prop
SetProperty:
If MsgBox("Turn on Bypass key?", vbYesNo, "Allow Bypass") = vbYes Then
CurrentDb.Properties("AllowByPassKey") = True
Else
CurrentDb.Properties("AllowByPassKey") = False
End If
End If
Me.Visible = False
Globals.Logging "Logon"
DoCmd.OpenForm "frm_Main"
End Sub
양식 frm_PassChange가 호출합니다. 이 양식에서 나는 사용자가 새 암호로 USERTABLE를 업데이트 할 다음 확인을 위해 새 암호의 2 배를 입력해야하지만이 작동하지 않습니다 :
Private Sub btnChangePass_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("X_tblUsers")
If Me.txtNewPass <> Me.txtNPConfirm Then
Me.lblPassMismatch.Visible = True
Me.txtNewPass.SetFocus
Exit Sub
End If
Me.lblPassMismatch.Visible = False
TempVars("Password").Value = Me.txtNewPass.Value
CurrentDb.Execute "Update X_tblUsers SET X_tblUsers.Password = Value(" & Me.txtNewPass.Value & ")"
Me.Visible = False
Globals.Logging "PWChange"
End Sub
어떻게 제대로 USERTABLE 업데이트를 수행합니까? 그와 몇 가지 문제가 있습니다
관리자가 아니든 아니든, 그들 중 누구도 시프트 키를 무시할 수 없어야합니다 :) :) 그들에게 통제 된 액세스 권한을 부여하지 말고 전체 액세스 권한을 부여하십시오! –