Make an Access Database 'expire'

Posted on 2008-10-05
Medium Priority
Last Modified: 2013-12-05
Is it possible to make a standard, desktop style MS Access database 'expire' after a pre-defined period of use?

This one at http://www.dropio.com/tasksdb would be such a candidate as it gets modified regularly.
Question by:verpit
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
LVL 26

Accepted Solution

dannywareham earned 800 total points
ID: 22644505
There are several ways of doing this.
However, none of them is perfect, as Access is a client-side database.
This means that a savvy user can get in and unsecure your system or the expiry.

The simplest way is to have a table with a field called "dtExpire". Have it with no value in at all.

On the first form you load, have code that checks to see if the expiry date has elapsed.
If there's no date (first opening), we put todays date in.

You could also write to teh registry of the PC. I can show how to do this - but it's a sledgehammer to crack a walnut...

Dim myRecordedDate as String
'lookup date
myRecordedDate = nz(dlookup("dtExpire", "tablename"),"Empty")
'insert expiry date if there is none
If myRecordedDate = "Empty" then
  CurrentDB.Execute "INSERT INTO yourtablename (dtExpire) SELECT " & chr(34) & format(now(),"dd-mmm-yy") + 30 & chr(34) & ";"
End if
If myRecordedDate>= Now() then
  'let em in
End if

Open in new window

LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 total points
ID: 22644523
You could "timestamp" the db, then use DateDiff to determine how long it's been in use. For example, add a custom Database Property named "DBTimeStamp", then compare that value at startup:

If DateDiff("m", CurrentDB.Properties("DBTimeStamp"), Now) >2 Then
  '/db is more than 2 months old
  Msgbox "This database is more than 2 months old. Contact the vendor for a new database.", vbOKOnly
End If

How to add custom database properties:
LVL 40

Assisted Solution

by:Vadim Rapp
Vadim Rapp earned 400 total points
ID: 22644646
  1. in Startup, specify startup form, and specify not to show database window, so the user has no way to use your database other than through the startup form
  2. in startup form, put a code that on 1st run creates secret registry key with the date, and on subsequent runs comparescurrent date to that key
  3. compile the database into ADE/MDE so the user can't see your code.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 22644834
all fantastic elements!   Thanks to dannywareham for his earlier tips as well, to LSM and vadimrapp1 on this one so far.

This is going to be one of those questions that takes some doing to explore.  Chances are the credit will be spread pretty thin.  I wish I had control over that and could give each person adequate credit.  This is going to take some brain power on my part so please bear with me and thanks again for chiming in.

OK so I think I will probably start with dannywareham's example and see if I can get that to work it seems like the most immediate solution that will both allow further development, and be least likely to run into permission issues with the OS itself.  Though I will be locking more tightly, I have to start peeling this onion slowly.  I will stop peeling and award credit as necessary as quickly as possible and post a follow-up.

dannywareham suggests:
"The simplest way is to have a table with a field called "dtExpire". Have it with no value in at all."  I will give this a go and paste his code.  

Is it best to have a separate table for this?

Updates always posted here.   Thanks again for the help.    

LVL 26

Expert Comment

ID: 22644851
>>Is it best to have a separate table for this?
Yes - and hide it.

There's no one way to do this, because Access is so easily hacked.
Saving as an MDE is a great way to secure your code (as it's not accessible to users at all).

Using the registry (with an MDE) is yet another more robust solution - but it all depends how secure you need teh db in teh first place.
If the answer is "really secure", then (unfortunatey) Access isn't the best db option...

Author Comment

ID: 22644970
Excellent!   Points well taken.

Is there a way to "wrapper" it somehow in another type of executable that isn't easily hacked?
LVL 26

Expert Comment

ID: 22644978
You can use Access as part of an exe - but it's a lot of work if you don't know a compilable language (C, C++, C#, VB, VB.Net etc)
Do you have Visual Studio or know these languages?

Author Comment

ID: 22645010
no, I don't :(
LVL 26

Assisted Solution

dannywareham earned 800 total points
ID: 22645048
In that case, the bronze medal goes to the suggestions already made:

1. Either use table method or registry method to record a date
2. Secure code by saving as MDE

LVL 40

Expert Comment

by:Vadim Rapp
ID: 22645434
Note that tables are visible to the user even in MDE. You can hide them, but all it takes is menu tools/options/hidden. You have to come up with some way to scramble the date visible in the table, and unscramble it in code.
LVL 26

Expert Comment

ID: 22645453
vadimrapp1 is right.
You can prefix with sys to hide (slightly) better. But this is one of the problems with Access.
There are always ways to get around it's inate security
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 400 total points
ID: 22648406

FWIW, here is a demo database from this site:
It is a sample of a 30 day demo Access database.


LVL 85
ID: 22648774
If you're looking for a commercial solution (i.e. you're going to build a commercial app using only Access) then there are a couple of products that can work with Access, although I'm not sure about 2007. Is this the type of thing you're looking for?

Author Closing Comment

ID: 31503175
excellent suggestions all

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question