Password Expiration Warning message
Hi All,
Please I need help with the vb script below. I wanted it to prompt users when their password is about expiring and on answering Yes, it should open a form frmChangepassword, hold it until the user enter a new password and save.
Right now, it opens the form without holding it, but goes on to open the second form Switchboard. When i close switchboard then the changepassword form will show behind the login1 form.
vb Code:
Private Sub fdate_Exit(Cancel As Integer)
If IsNull(Forms![login1]![fname]) Or IsNull(Forms![login1]![fpassword]) Then
MsgBox ("Unauthorised User")
Else
If Forms![login1]![fdate] > Now() Or IsNull(Forms![login1]![fdate]) Then
MsgBox ("Date is in the future or Cannot Be Blank")
Else
If IsNull(Forms![login1]![Ulevel]) Then
MsgBox ("User Does Not Exist or Password Is Not Correct")
fname = ""
fpassword = ""
fname.SetFocus
Exit Sub
Else
'********
'** The following statements check for password aging / expiring
If DateDiff("d", gDate, Now) > gPasswordAge Then
MsgBox "Password has expired, please change your password"
gStatus = "Expired"
DoCmd.OpenForm "frmchangepassword", acNormal, , , , acWindowNormal
Exit Sub
End If
' If DateDiff("d", gDate, Now) > 30 Then MsgBox "Your passord will expire in " & Str$(46 - DateDiff("d", gDate, Now)) & " days !"
'This is where am having problem with''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Reply As String
If DateDiff("d", gDate, Now) > (gPasswordAge - 15) Then
Reply = MsgBox("Your password will expire in " & Str$((gPasswordAge + 1) - DateDiff("d", gDate, Now)) & " days !,Do you want to change it now?", vbYesNo)
End If
If Reply = vbYes Then
DoCmd.OpenForm "frmChangePassword", acNormal, , , , acWindowNormal, vbModal
Else
DoCmd.OpenForm "switchboard", acNormal, , , , acWindowNormal
Exit Sub
End If
'***** End of password / expiring aging verification
gUserID = ""
If Forms![login1]![Ulevel] = "2" Then
'DoCmd.OpenForm ("SelectReport")
DoCmd.OpenForm ("switchboard")
Else
DoCmd.OpenForm ("switchboard")
Me.AllowEdits = True
Me.AllowAdditions = False
End If
End If
End If
End If
Forms.Item("login1").Properties.Item("visible") = False
End Sub
Re: Password Expiration Warning message
Thread moved to 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt
Re: Password Expiration Warning message
Welcome to the forums. :wave:
Your code is kind of going all over the place. With it properly indented, I can see where the problem you describe exists. Can you?
Re: Password Expiration Warning message
Thanks Hack for adding highlight tags and indenting to my code.