How to make this pasword will expires in 15 days

F

Frank Situmorang

Hello,

This is my VBA for pasword in the textbox, How can I make it expires in 15
days after they 1st run it in their computer.

Private Sub txtPassword_AfterUpdate()
If Me.txtPassword = "hfs1754" Then
'Do something
DoCmd.Close
DoCmd.OpenForm "Switchboard"
Else
MsgBox "Password yang dimasukkan salah"
'Do something else
DoCmd.Close
End If

End Sub

Thanks in advance
 
J

John W. Vinson

Hello,

This is my VBA for pasword in the textbox, How can I make it expires in 15
days after they 1st run it in their computer.

Private Sub txtPassword_AfterUpdate()
If Me.txtPassword = "hfs1754" Then
'Do something
DoCmd.Close
DoCmd.OpenForm "Switchboard"
Else
MsgBox "Password yang dimasukkan salah"
'Do something else
DoCmd.Close
End If

End Sub

Thanks in advance

You will need to store the date of the first run somewhere, in a table
perhaps, and check that date.

Just be aware that this is very weak security; anyone who can open the form in
design view or locate your stored date can break it.
 
F

Frank Situmorang

Thanks John for your response, what intended to do is to make the file MDE
after i put the VBA to make it expire in 15 days, that is why if you could
just continue my VBA maybe to put a Today as a constant? then minus 15 if
Const < then something can not open.

Thanks for your help
 
J

John W. Vinson

Thanks John for your response, what intended to do is to make the file MDE
after i put the VBA to make it expire in 15 days, that is why if you could
just continue my VBA maybe to put a Today as a constant? then minus 15 if
Const < then something can not open.

Thanks for your help

The trouble with that is that you must edit the code and put in the start date
yourself. Suppose the person is unable to open the database for two weeks?
They only get one day to test it!

If that is what you want to do, then yes, you can hardcode the date:

Private Sub txtPassword_AfterUpdate()
Dim dtStart As Date
dtStart = #2008-03-14# ' you must edit this date for each customer
If DateDiff("d", dtStart, Date) > 15 Then
MsgBox "Test period has expired"
Application.Quit ' exit the database
End If
If Me.txtPassword = "hfs1754" Then
DoCmd.OpenForm "Switchboard"
DoCmd.Close, acDataForm, Me.Name
Else
MsgBox "Password yang dimasukkan salah"
'Do something else
Application.Quit ' if you want the user to be thrown out
DoCmd.Close
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top