Results 1 to 7 of 7
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Password Expire In One Month

    Hi Guys



    Code:
    Private Sub Command12_Click()Dim User As String
    Dim UserLevel As Integer
    Dim TempPass As String
    Dim ID As Integer
    Dim UserName As String
    Dim TempID As String
    Dim but As String
    Dim SysID As String
    
    
    If IsNull(Me.txtUserName) Then
     MsgBox "Please Enter User Name", vbInformation, "Username required"
     Me.txtUserName.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
     MsgBox "Please Enter Password", vbInformation, "Password required"
     Me.txtPassword.SetFocus
    Else
     If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
     MsgBox "Invalid Username or Password!"
     Else
     TempID = Me.txtUserName.Value
     UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     ID = DLookup("[ID]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     but = "Login"
     SysID = Environ("username")
     CurrentDb.Execute "INSERT INTO UserLog (User_name,Log_Type, Log_Time, Log_Date,Computer_User)" & " VALUES ('" & Me.txtUserName & "','" & but & "',Now(),Now(),'" & SysID & "')"
     DoCmd.Close
     If (TempPass = "password") Then
     MsgBox "Please change Password", vbInformation, "New password required"
     DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
     Else
     'open different form according to user level
     If UserLevel = 1 Then ' for admin
     DoCmd.OpenForm "Navigation Form"
     ElseIf UserLevel = 2 Then ' for academic
     DoCmd.OpenForm "Navigation Form"
     ElseIf UserLevel = 3 Then ' for exam
     DoCmd.OpenForm "Navigation Form"
     Else
     DoCmd.OpenForm "Main_Menu_2"
     Forms![Navigation Form]![Text861] = UserLogin
     Forms![Main_Menu_2]!Command19.Enabled = False
     End If
    
    
     End If
     End If
    End If
    End Sub

    i used above code for login, now i want password to be expired in 30 days and enter new password, how to do this part?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Do you have a date field in your tblUser table that holds the PasswordDate? If no add it, then simply add the logic into your login procedure: you dim a datPassDate as Date variable and a intDaysOld as integer variable, get the value from the table using a dlookup like datPassDate =DLookup("[PasswordDate]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'"), then you check how old it is intDaysOld=Date()-datPassDate, if over 30 you open the change password form and exit the procedure.

    Cheers,
    Vlad

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    HI

    Where do i place the below code ?

    intDaysOld=Date()-datPassDate,

  4. #4
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    HI

    Code:
    Dim User As StringDim UserLevel As Integer
    Dim TempPass As String
    Dim ID As Integer
    Dim UserName As String
    Dim TempID As String
    Dim but As String
    Dim SysID As String
    Dim datPassDate As Date
    Dim intDaysOld As Integer
    
    
    intDaysOld = 1
    If IsNull(Me.txtUserName) Then
     MsgBox "Please Enter User Name", vbInformation, "Username required"
     Me.txtUserName.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
     MsgBox "Please Enter Password", vbInformation, "Password required"
     Me.txtPassword.SetFocus
    Else
     If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
     MsgBox "Invalid Username or Password!"
     Else
     TempID = Me.txtUserName.Value
     UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     ID = DLookup("[ID]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     datPassDate = DLookup("[PDate]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
     but = "Login"
     SysID = Environ("username")
     CurrentDb.Execute "INSERT INTO UserLog (User_name,Log_Type, Log_Time, Log_Date,Computer_User)" & " VALUES ('" & Me.txtUserName & "','" & but & "',Now(),Now(),'" & SysID & "')"
     DoCmd.Close
     If (TempPass = "password") Then
     MsgBox "Please change Password", vbInformation, "New password required"
     DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
     ElseIf (intDaysOld > Date - datPassDate) Then
      MsgBox "Password Expired Please change Password", vbInformation, "New password required"
      DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
     Else
     'open different form according to user level
     If UserLevel = 1 Then ' for admin
     DoCmd.OpenForm "Navigation Form"
     ElseIf UserLevel = 2 Then ' for academic
     DoCmd.OpenForm "Navigation Form"
     ElseIf UserLevel = 3 Then ' for exam
     DoCmd.OpenForm "Navigation Form"
     Else
     DoCmd.OpenForm "Main_Menu_2"
     End If
    
    
     End If
     End If
    End If
    please see above code and let me know whether i have placed it in the correct places.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Please see below:
    Code:
    Dim User As String
    Dim UserLevel As Integer
    Dim TempPass As String
    Dim ID As Integer
    Dim UserName As String
    Dim TempID As String
    Dim but As String
    Dim SysID As String
    Dim datPassDate As Date
    Dim intDaysOld As Integer
    
    
    
    
    
    
    If IsNull(Me.txtUserName) Then
        MsgBox "Please Enter User Name", vbInformation, "Username required"
        Me.txtUserName.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
        MsgBox "Please Enter Password", vbInformation, "Password required"
        Me.txtPassword.SetFocus
    Else
         If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
            MsgBox "Invalid Username or Password!"
         Else
            TempID = Me.txtUserName.Value
            UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            ID = DLookup("[ID]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            datPassDate = DLookup("[PDate]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
            intDaysOld = Date - Nz(datPassDate, Date)
            but = "Login"
            SysID = Environ("username")
            CurrentDb.Execute "INSERT INTO UserLog (User_name,Log_Type, Log_Time, Log_Date,Computer_User)" & " VALUES ('" & Me.txtUserName & "','" & but & "',Now(),Now(),'" & SysID & "')"
            DoCmd.Close
            
            If (TempPass = "password") Then
                MsgBox "Please change Password", vbInformation, "New password required"
                DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
            ElseIf intDaysOld > 30 Then
                MsgBox "Password Expired Please change Password", vbInformation, "New password required"
                DoCmd.OpenForm "frmUserinfo", , , "[ID] = " & ID
            Else
                'open different form according to user level
                If UserLevel = 1 Then ' for admin
                    DoCmd.OpenForm "Navigation Form"
                ElseIf UserLevel = 2 Then ' for academic
                    DoCmd.OpenForm "Navigation Form"
                ElseIf UserLevel = 3 Then ' for exam
                    DoCmd.OpenForm "Navigation Form"
                Else
                    DoCmd.OpenForm "Main_Menu_2"
                End If
            End If
        End If
    End If
    Also, if not already there you need to reset the PDate from frmUSerInfo when new password is entered.

    Cheers,
    Vlad

  6. #6
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi Gicu


    awesome, that worked.


    thanks alot mate.

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Glad to help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-03-2016, 03:58 AM
  2. Replies: 1
    Last Post: 07-05-2014, 05:04 PM
  3. Replies: 3
    Last Post: 05-01-2013, 02:47 PM
  4. making expire ms access form..
    By alex_raju in forum Access
    Replies: 2
    Last Post: 07-13-2011, 11:27 AM
  5. Set Database to Expire in time period
    By robsworld78 in forum Access
    Replies: 12
    Last Post: 06-07-2011, 06:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums