Will it Work-Code for Distributing Safe Software?

  • Thread starter Thread starter John Phelan
  • Start date Start date
J

John Phelan

What do you think of the following code for limiting demos
to two months? Will it work?

'On the opening form or switchboard I hard code the
following:

Private Sub Form_Activate()
Dim TodayDate, CutoffDate As Date
CutoffDate = DateAdd("m", 2, Now)
TodayDate = Date
' Program will not run after 2 months ("m", 2,Now) from
installation date (TodayDate).
If CutoffDate > TodayDate Then
MsgBox("The Trial Period has Expired
DoCmd.Quit
End If
End Sub

'I put the same code into the Form_Open() and/or Form_Load
() .

John
 
Private Sub Form_Activate()
Dim TodayDate, CutoffDate As Date
CutoffDate = DateAdd("m", 2, Now)
TodayDate = Date

This will NOT work, since Date() and Now() return the same date -
Now() includes the current time as well as the date.

But CutOffDate will be two months in the future, and TodayDate will be
today's date, no matter when you run this code; the cutoff date will
keep retreating into the future forever.

You'll need to store the activation date in a Table or (if you're
bold) in an encrypted Registry key. If you use a Table consider naming
it with a name beginning with USys - Access will treat it as a System
table; also make its Hidden property True. This won't defeat a
determined person who's knowledgable in Access, but it will make it
harder for the garden-variety hacker and (like most locks) it will
keep the honest people out.
 
Back
Top