I have a simple Login System that, among other features, has a password expiration feature built in. Simply, the first time a user logs in they are required to enter their own password. At that time the record in the table which holds their account information gets added to it a date that is 30 days into the future. This part works fine.
The problem i'm encountering is checking against that date each time the user logs in. As part of the login form, during the UnLoad event, it checks the date that was placed in their account record and if that date has been reached or surpassed, it forces the user to create a new password (and thus, updates the date to a new +30 day date.)
The VBA I am attempting to use looks at the stored date and checks if it is less than or equal to the current date, represented with <= Date(). Running this code, even if the date qualifies, it simply moves past it as if the condition has not been met. If I replace <= Date() with a hard coded date that matches the stored date, such as simply typing "12/1/2012" as the value, it functions correctly so I know the logic in the statement is correct.
When debugging and stepping through the code, Me.cbo_Uname.Column(3) shows a value of "12/1/2012" and Date() shows a value of "1/15/2013". I'm confused because, mathematically, 12/1/2012 is less than or equal to 1/15/2013.
And, before anyone mentions it, yes I know using underscores in control names isn't the best idea, but i'm fine with it. And, Access is automatically changing Date() to Date in the second "If" statement, so I manually added the parenthesis back in for illustration purposes.
Ideas?
The problem i'm encountering is checking against that date each time the user logs in. As part of the login form, during the UnLoad event, it checks the date that was placed in their account record and if that date has been reached or surpassed, it forces the user to create a new password (and thus, updates the date to a new +30 day date.)
The VBA I am attempting to use looks at the stored date and checks if it is less than or equal to the current date, represented with <= Date(). Running this code, even if the date qualifies, it simply moves past it as if the condition has not been met. If I replace <= Date() with a hard coded date that matches the stored date, such as simply typing "12/1/2012" as the value, it functions correctly so I know the logic in the statement is correct.
Code:
Private Sub Form_Unload(Cancel As Integer)
If Me.txt_PWord = "CAD2013" Or Me.txt_PWord = "cad2013" Then
MsgBox "You must choose your own Password now", vbOKOnly, _
"Password change required"
DoCmd.OpenForm "frm_ChangePword_AutoName"
Exit Sub
End If
If Me.cbo_Uname.Column(3) <= Date() Then
MsgBox "Your Password has expired." & vbCrLf & "Please create a new Password.", vbOKOnly, _
"Password change required"
DoCmd.OpenForm "frm_ChangePword_AutoName"
Exit Sub
End If
End Sub
When debugging and stepping through the code, Me.cbo_Uname.Column(3) shows a value of "12/1/2012" and Date() shows a value of "1/15/2013". I'm confused because, mathematically, 12/1/2012 is less than or equal to 1/15/2013.
And, before anyone mentions it, yes I know using underscores in control names isn't the best idea, but i'm fine with it. And, Access is automatically changing Date() to Date in the second "If" statement, so I manually added the parenthesis back in for illustration purposes.
Ideas?
Last edited: