Originally Posted by
hwinceFL
Hello Scott, Thanks for your response. Obviously, I should not, at my level of skill, state that my coding is "without error."
My effort relates to my attempt to modify your Login Security procedure at the point of frmPasswordChange. Here I am trying to require an entry of a new password of maximum 8 alphanumeric characters with at least one upper-case and one number. I am trying to test the txtpassword in the AfterUpdate event procedure with the following coding, which is where I get the previously-described Compile Error. I appreciate your consideration and clarification of my effort.
Option Compare Database
Option Explicit
Private Sub txtConfPW_AfterUpdate()
' Verify new password match
If Me.txtPassword = Me.txtConfPW Then
MsgBox "Password updated!", vbOKOnly
Me.PWReset = False
' The following is intended to record the effective date of PW change.
' Dim NewDate As Date
' MsgBox "The new password effective date is " & [NewDate]
' Me.PWDate = NewDate
DoCmd.Close acForm, "frmPasswordChange"
Else
MsgBox "Passwords don't match; please re-enter!", vbOKOnly
Me.txtPassword.SetFocus
End If
End Sub
Private Sub txtPassword_AfterUpdate()
' Test new password for valid format
If Len(Me.txtPassword) < 2 Then
Err_PW_Num:
MsgBox "New password must be 2 to 8 alphanumeric; re-enter", vbOKOnly
CleanUp:
' Me.cboUser = Null Re-set Select User box
Me.txtPassword = Null
Me.txtPassword.SetFocus
ElseIf Len(Me.txtPassword) > 8 Then
Go to Err_PW_Num
End If
Dim NumCheck As Integer
Dim CapCheck As Integer
Dim ICount As Integer
Dim intChar As Integer
NumCheck = 0
CapCheck = 0
ICount = 0
intChar = 0
For ICount = 1 To Len(Me.txtPassword)
' For ICount = 1 To 8
intChar = Asc(Mid(Me.txtPassword, ICount, 1))
Select Case intChar
Case 48 - 57 'Select a number
NumCheck = NumCheck + 1
Go to LoopOn
Case 65 - 90 'Select an upper-case letter
CapCheck = CapCheck + 1
Go to LoopOn
Case 96 - 122 'Select lower-case letter
Go to LoopOn
' Case Is < 65 Or 91 - 96 Or 123 - 267
MsgBox "Non-alphanumeric characters are invalid.", vbOKOnly
Go to CleanUp
LoopOn:
Next ICount
End Select
If NumCheck = 0 Then
MsgBox "Password must contain at least one number."
Go to CleanUp
' End If
ElseIf CapCheck = 0 Then
MsgBox "Password must contain at least one uppercase letter."
Go to CleanUp
End If
End Sub