Solved

Make an Access Database 'expire'

Posted on 2008-10-05
14
427 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
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
  '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
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
  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
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.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

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

0
 
LVL 26

Expert Comment

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

Author Comment

by:verpit
ID: 22644970
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
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?
0
 

Author Comment

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

Assisted Solution

by:dannywareham
dannywareham earned 200 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

0
 
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.
0
 
LVL 26

Expert Comment

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

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
ID: 22648406
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
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?
0
 

Author Closing Comment

by:verpit
ID: 31503175
excellent suggestions all
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modal form 11 30
DSN-LESS connection to MS Access database 6 29
date criteria to pull up records for the last 3 months 39 42
Field naming convntions - MS Access 7 28
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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