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