How to set the expired date to database

How to set the expired date to database: MS Access

In this How To, I will illustrate how to set the expired date to database in two different methods: 1. Set program to expire and the expired date cannot be changed mostly used in the demo file or .accde file. 2. Set program to expire and the Admin with a password can change the expired date on the VBA code. You have the option to choose the method that suitable to your purpose. The details and VBA code will be illustrated below:

 Set expired date that cannot be changed

Step by Step: 1. Create a public function called SetExpired() in the Module of Access 2. Assign the expired date in the function (5/31/2013 for example). How it works: if today date is greater than 5/31/13 then the message “This demo has expired. Please contact the developer for the latest version.” will pop-up. After the Ok button is clicked then the database will close. The user doesn’t have any option other than click Ok to close program.

Public Function SetExpired()
On Error GoTo ErrHandler:
If (Date > #5/31/2013#) Then
    MsgBox "This demo has expired." & vbCrLf & vbCrLf & _
    "Please contact the developer" & vbCrLf & _
    "for the latest version.", vbInformation + vbOKOnly, "Demo Expired!"
DoCmd.Quit
End If
Exit_ErrHandler:
Exit Function
ErrHandler:
   MsgBox Err.Description, vbCritical
   Err.Clear
End Function

3. Call a function on the On Load Event Procedure on the form that first loaded on your database. In this HowTo, I will call the SetExpired() function on form “Login Form.” Note: Before you do this step, you should make a copy of your database.

PutOnloadThough with tender care and counselling, it is also possible to never relapse again.However, you will need the aid of your loved ones. http://raindogscine.com/?attachment_id=303 tadalafil cialis Medication may however not work well with those affected by psychological causes. check it right here now on line viagra After looking at such worst situations pills for online cialis erectile dysfunction. This caution is the same for those who take achat cialis cipla as well. viagra also contain DHEA, which is a hormone that several men are deficient in.

Private Sub Form_Load()
Call SetExpired
End Sub

4. When a Login Form is loaded then a pop-up message shown below will pop-up due to the expired date is set to 5/31/2013. After the Ok button is clicked, the database will close. It doesn’t give you any option to enter a password to open the database. This method is most likely used for a demo program or .accde Access file format.

demoexp

Set expired date that can be changed by admin with password

Step by Step:

1. Create a public function called ExpiredDate() in the Module of Access. Assign the expired date in the function (5/31/2013 for example)

How it works:
  1. If today date is greater than 5/31/13 then the message “End of free period, Please contact the developer.” will pop-up. If the Ok button is clicked then the database will close. If the Cancel button is clicked then the message box “Please Enter Password” will pop-up.
  2. If a correct password is entered then open a Login Form to login database
  3. If the incorrect password or no password entered then shows a message 3 times to re-enter a password then exit program
Public Function ExpiredDate()
On Error GoTo ErrHandler:
If (Date > #5/31/2013#) Then
   Msg = "End of free period, Please contact the Developer"
       Style = vbOKCancel + vbCritical
       Title = "Critical Database Error"
       DBErr = MsgBox(Msg, Style, Title, Help, Ctxt)
   If DBErr = vbOK Then
     Application.Quit
   Exit Function
   End If
   If DBErr = vbCancel Then
   Dim strPasswd As String
   Dim counter As Integer
   Dim Remaining As Integer
   counter = 0
   Do Until counter = 3
   strPasswd = InputBox("Please Enter Password", "Password Required")
   'If a correct password is entered, open a Login Form
   'If incorrect password or no password entered then shows a message
   'for 3 times to re-enter a password then exit program
       If strPasswd = "5555" Then
           DoCmd.OpenForm "Login form", acNormal
           Forms![Login Form]!txtUserName.SetFocus
           Exit Function
       Else
           counter = counter + 1
           Remaining = 3 - counter
           MsgBox "Wrong password or Incorrect password!" & vbCrLf & _
                   "You have " & Remaining & " attempt(s) remaining!", _
                   vbOKOnly, "Password Info"
       End If
       Loop
         Application.Quit
       Exit Function
   End If
End If
Exit_ErrHandler:
Exit Function
ErrHandler:
         MsgBox Err.Description, vbCritical
         Err.Clear
End Function

2. Call an ExpiredDate() function on the On Load Event Procedure on the form that first loaded on your database. In this HowTo, I will use a function on the “Login Form.” Note: Before do this step, you should make a copy of your database. PutOnload

Private Sub Form_Load()
Call ExpiredDate
End Sub

3. When the Login Form is loaded then the message “End of free period, Please contact the developer” will pop-up due to the expired date is set to 5/31/2013. After the Ok button is clicked the database will close. If the Cancel button is clicked then it asks users to enter a password. ExpiredMess           askPassword         4. Per the code above, the password is set to “5555.” If a correct password is entered then it will open a Login Form. Then the Admin can open database and change the due date on the ExpiredDate() function in the Module. 5. If the incorrect password or no password entered then the message box of incorrect password and the number of attempt remaining will pop-up. It will allow 3 times to re-enter a password as a counter is set to 3 (Do Until counter = 3), then exit program wrongpass

           

 

Related posts