Solved

Make an Access Database 'expire'

Posted on 2008-10-05
14
425 Views
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.
0
Comment
Question by:verpit
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 26

Accepted Solution

by:
dannywareham earned 200 total points
Comment Utility
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

  'expired

  application.quit

Else

  'let em in
 

End if

Open in new window

0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 total points
Comment Utility
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
  Application.Quit
End If

How to add custom database properties:
http://www.allenbrowne.com/ser-09.html
0
 
LVL 40

Assisted Solution

by:Vadim Rapp
Vadim Rapp earned 100 total points
Comment Utility
  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.
0
 

Author Comment

by:verpit
Comment Utility
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.    

0
 
LVL 26

Expert Comment

by:dannywareham
Comment Utility
>>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...
:-)
0
 

Author Comment

by:verpit
Comment Utility
Excellent!   Points well taken.

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

Expert Comment

by:dannywareham
Comment Utility
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?
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:verpit
Comment Utility
no, I don't :(
0
 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 200 total points
Comment Utility
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

0
 
LVL 40

Expert Comment

by:Vadim Rapp
Comment Utility
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.
0
 
LVL 26

Expert Comment

by:dannywareham
Comment Utility
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
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
Comment Utility
verpit,

FWIW, here is a demo database from this site:
http://www.aadconsulting.com/
It is a sample of a 30 day demo Access database.

http://www.aadconsulting.com/demodbase.zip

JeffCoachman
0
 
LVL 84
Comment Utility
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?
0
 

Author Closing Comment

by:verpit
Comment Utility
excellent suggestions all
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now