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

Is there a way to create a demo database in Access 2010 that would become not useable after a certain length of time?
Who is Participating?
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.
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.
SteveL13Author Commented:
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?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

    '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 = ""
    '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

    '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

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
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".

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.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
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.
SteveL13Author Commented:
Thank you to all of you who provided extremely great input.  I appreciate it.
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.

All Courses

From novice to tech pro — start learning today.