Disable a DB (1 Viewer)

BobNTN

Registered User.
Local time
Yesterday, 22:06
Joined
Jan 23, 2008
Messages
308
Anyone know how I can have an Access program disable itself automatically on a given date without damaging the data but still be able to open (by programmer) and enable it ?
 

DCrake

Remembered
Local time
Today, 03:06
Joined
Jun 8, 2005
Messages
8,632
Code:
Private Sub Form_Open(Cancel As Integer)
    Dim ExpiryDate As Date
    Dim UnlockCode As String
    
    ExpiryDate = GetCustomProp("Date completed")
           
    If DateDiff("d", Now(), ExpiryDate) < 0 Then
        ' if the software has already been unlocked once then don't give the option again
        If IsNull(GetCustomProp("Telephone Number")) = False Then
            MsgBox "License expired. Please contact Supplier to unlock this software."
            DoCmd.RunCommand acCmdCloseDatabase
            Exit Sub
        End If
        
        ' if it hasn't then ask for unlock code
        UnlockCode = InputBox("Your license to use this software has expired. Please contact Supplier to renew your license. If you have an unlock code please enter it here:")
        If UnlockCode = "PADLOCK" Then
            SetCustomProp "Date completed", Format(DateAdd("d", 7, Now()), "dd/mm/yyyy")
            
            CreateCustomProp "Telephone number", dbText, "11111111" ' existence of this custom prop indicates the software has already been unlocked once and can't be unlocked again
            MsgBox "Software unlocked. Your license has been renewed for 7 days."
            Exit Sub
        Else
            MsgBox "No code / incorrect code entered. Please contact Supplier."
            DoCmd.Close
            Exit Sub
        End If
    End If
    
    ExpiryDate = GetCustomProp("Date completed")
    
    ' warning if getting near expiry date
    If DateDiff("d", Now(), ExpiryDate) < 14 Then
        MsgBox "Warning, this software will expire in " & DateDiff("d", Now(), ExpiryDate) & " days. Contact Supplier to renew your license."
    End If


End Sub


GetCustomProp("Date completed")

Is a custom property of the database that holds an expiry date.
 

BobNTN

Registered User.
Local time
Yesterday, 22:06
Joined
Jan 23, 2008
Messages
308
Thanks David

1. What form does this code go in if in a form ?
 
Last edited:

BobNTN

Registered User.
Local time
Yesterday, 22:06
Joined
Jan 23, 2008
Messages
308
Ok, as usual, I am confused as to where I set the execution date of this.
All I need is say, on March 3, 2011, it pops up a message that the license has expired, enter an unlock code. If code not correct, states unlock code incorrect and does not start. Don't need a warning or if previously unlocked condition.
Since I know who is trying to use it won't have the unlock code anyway.
I KNOW someone is going to steal my program and try to use it.
 
Last edited:

Users who are viewing this thread

Top Bottom