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




Reply With Quote