Close DB if date has expired

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to state a date in the future and check if todays date is greater than
it.
If it is the close and exit the DB.

Anyone any examples on how to do this?

thanks

Ashby
 
Ashby said:
I need to state a date in the future and check if todays date is
greater than it.
If it is the close and exit the DB.

Anyone any examples on how to do this?

It's not clear how you intend to establish the future date in question.
But suppose you had it stored in a table named "Configuration", in a
field named "ExpDate", in the first or only record in that table. Then
you could have code like this:

If DLookup("ExpDate", "Configuration") < Date() Then
DoCmd.Quit
End If

Of course, you'd need to pick some suitable event to run this code.
Also, if your intention is to set a time limit on a trial version of
your application, this is clearly not at all difficult to detect and
circumvent.
 
Hi, Ashby.
If it is the close and exit the DB.

Anyone any examples on how to do this?

In the OnOpen( ) event of the startup form, place the following code:

If (Date() > #2/28/2007#) Then
MsgBox "This demo application has expired."
Application.Quit
End If

Replace the date with your expiration date, then create an MDE database file
to hide this VBA code, so that the users can't change the date. And don't
be surprised if the users are still using your application long after the
original expiration date, because all they have to do is hold the shift key
down when opening the file to bypass the startup options, or set the system
clock back to before the expiration date.

In other words, expiring a database application within the application isn't
very effective.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
Back
Top