How create a "demo" database which would timeout after a certain time period

Posted on 2014-03-08
Medium Priority
Last Modified: 2014-03-10
Is there a way to create a demo database in Access 2010 that would become not useable after a certain length of time?
Question by:SteveL13
LVL 10

Accepted Solution

Korbus earned 336 total points
ID: 39914949
You probably have an autoexec startup macro already in place, if not, set one up.  In this macro, look up the “expiration date” in a table, or hard code it in.  If the current date is later than the expiration date; open up an “expired” message box, rather than your main form.  You could also delete certain forms or queries at this point; so they can’t just change their computer date once they see the “expired” message.  (Let us know if you need more details on how to do this stuff.)
Of course, this will not stop any determined, advanced user.  For that you must prevent the user from modifying the auto-exec macro, and the expiration date table.  Unfortunately access user security has changed in I used access a lot, and I’m not really up to speed on it anymore.  But I’m sure another expert will have some input on this.
LVL 28

Expert Comment

ID: 39914959
I imagine it would be for licensing purposes...

The only way to effectively do so is to hard code the expiring date. Then every time the database is opened you can check the current date and if it is larger than than expiring date close the program.

1. The database has to be compiled (accde or ade), otherwise the code can be tampered with (even if you set a vba project password it can easily be cracked).
2. The users can change the date of their computer, so to effectively work you will have to compare the time with an online time server.

Author Comment

ID: 39914971
So I suppose I could do an onopen event of the form that opens when the database is launched.  I could have a Dlookup in the onopen event to lookup an expiration date and compare it to the today's date.

But then for today's date how would I lookup an online time server?
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

LVL 28

Assisted Solution

MacroShadow earned 336 total points
ID: 39915035
I found this here:

Option Explicit

Function InternetTime(Optional GMTDifference As Integer) As Date

    'This function returns the Greenwich Mean Time retrieved from an internet server.
    'You can use the optional argument GMTDifference in order to add (or subtract)
    'an hour from the GMT time. For Example if you call the function as:
    '=InternetTIme(2) it will return the (local) hour GMT + 2. Note that the
    'GMTDifference variable is an integer number.
    'Written by:    Christos Samaras
    'Date:          25/09/2013
    'Last Updated:  20/11/2013
    'e-mail:        xristos.samaras@gmail.com
    'site:          http://www.myengineeringworld.net

    'Declaring the necessary variables.
    Dim Request     As Object
    Dim ServerURL   As String
    Dim Results     As String
    Dim NetDate     As String
    Dim NetTime     As Date
    Dim LocalDate   As Date
    Dim LocalTime   As Date
    'Check if the time difference is within the accepted range.
    If GMTDifference < -12 Or GMTDifference > 14 Then
        Exit Function
    End If

    'The server address.
    ServerURL = "http://www.timeanddate.com/worldclock/fullscreen.html?n=2"
    'Build the XMLHTTP object and check if was created successfully.
    On Error Resume Next
    Set Request = CreateObject("Microsoft.XMLHTTP")
    If Err.Number <> 0 Then
        Exit Function
    End If
    On Error GoTo 0
    'Create the request.
    Request.Open "GET", ServerURL, False, "", ""
    'Send the request to the internet server.
    'Based on the status node result, proceed accordingly.
    If Request.ReadyState = 4 Then
        'If the request succeed, the following line will return
        'something like this: Mon, 30 Sep 2013 18:33:23 GMT.
        Results = Request.getResponseHeader("date")
        'Use the Mid function to get something like: 30 Sep 2013 18:33:23.
        Results = Mid(Results, 6, Len(Results) - 9)
        'Use the Left and Right function to distinguish the date and time.
        NetDate = Left(Results, Len(Results) - 9) '30 Sep 2013
        NetTime = Right(Results, 8) '18:33:23
        'Convert the date into a valid Excel date 30 Sep 2013 -> 30/9/2013.
        'Required for countries that have some non-Latin characters at their alphabet (Greece, Russia, Serbia etc.).
        LocalDate = ConvertDate(NetDate)

        'Add the hour difference to the retrieved GMT time.
        LocalTime = NetTime + GMTDifference / 24

        'Return the local date and time.
        InternetTime = LocalDate + LocalTime
    End If
    'Release the XMLHTTP object.
    Set Request = Nothing

End Function

Function ConvertDate(strDate As String) As Date

    'This function converts the input date into a valid Excel date.
    'For example the 30 Sep 2013 becomes 30/9/2013.
    'Required for countries that have non-Latin characters at their alphabet.

    'Written by:    Christos Samaras
    'Date:          25/09/2013
    'e-mail:        xristos.samaras@gmail.com
    'site:          http://www.myengineeringworld.net

    'Declaring the necessary variables.
    Dim MyMonth As Integer

    'Check the month and convert it to number.
    Select Case UCase(Mid(strDate, 4, 3))
        Case "JAN": MyMonth = 1
        Case "FEB": MyMonth = 2
        Case "MAR": MyMonth = 3
        Case "APR": MyMonth = 4
        Case "MAY": MyMonth = 5
        Case "JUN": MyMonth = 6
        Case "JUL": MyMonth = 7
        Case "AUG": MyMonth = 8
        Case "SEP": MyMonth = 9
        Case "OCT": MyMonth = 10
        Case "NOV": MyMonth = 11
        Case "DEC": MyMonth = 12
    End Select

    'Rebuild the date.
    ConvertDate = DateValue(Left(strDate, 2) & "/" & MyMonth & "/" & Right(strDate, 4))

End Function

Open in new window

LVL 59

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 332 total points
ID: 39915042
There are so many in's and out's to this, I would not suggest re-inventing the wheel, but rather:


  But as the others have said, you'll need some kind of check, but don't place it in the autoexec, which can be bypassed.

 Place you check in code, and you'll need to distribute as a MDE, or put a password on the VBA project.

 The check/restriction may take any number of forms:

1. Expiration date
2. Limit the number of records allowed in key table (ie. can only enter five customers).
3. Limit number of users
4. Tie to a specific hard drive
5. Don't allow the company name to be changed and print it out on all reports "DEMO DB - NOT FOR COMMERCIAL USE".

LVL 41

Assisted Solution

PatHartman earned 332 total points
ID: 39915156
I create a "token".  Mine is 16 digits and in addition to the expiration date includes other flags to turn on/off application features.  I also use a check digit which makes it more difficult to randomly come up with a working code.  The check digit is never the first or last character since those positions are too obvious and the date is never mmddyy all together, the characters are spread around in some different order.  I use different conversion schemes for different positions so pos 4 which might be the day part of the expiration month uses 31 characters from the set of a-z, A-Z, and 0-9.  I generally omit zero and the letters O, l, and I.  So, I create an array using 31 of those characters in a random order.  Day 1 is array(1), day 2 is array(2), etc.  I use a 1 based array for my sanity.

This method allows you to send the client a new token with a different expiration date if he purchases or renews.  It does not prevent multiple installs though.  You need something like the product sold on Peter's Software site.  This works for my software because it is business specific and not something that people are inclined to share with each other.  Plus, I price the product to account for multiple installs.
LVL 86

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 332 total points
ID: 39915688
I've used this:


I have the .NET and ActiveX versions, and they work very well, and are easy to use and deploy. It provides standard licensing schemes (i.e. number of uses, expiration date, etc etc) and includes logic to detect date rollbacks and such. It can be tied to a specific machine, or you can create one that will allow your program to be installed x number of times.
LVL 47

Assisted Solution

aikimark earned 332 total points
ID: 39916478
1. You need to persist the form and report open/close datetime values.  Logging is generally useful for debugging.  The event log should be hidden and the data lightly encrypted with a key specific to each user/PC.

2. If the database is opened read-only, prevent anything useful from happening.

3. If possible, externalize something that will help you know that the expiration date has been passed.

4. Use Nag Screens to remind your users that the demo/lease is set to expire in a few days.  I start showing these about two weeks out.

5. Facilitate the extension of the demo/lease period with a license file.

Author Closing Comment

ID: 39917314
Thank you to all of you who provided extremely great input.  I appreciate it.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

597 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