[Last Call] Learn how to a build a cloud-first strategyRegister Now


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?
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

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 58

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 40

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 85

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 46

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

830 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