Time-limiting feature (trial period)

mergle

Registered User.
Local time
Today, 16:49
Joined
Jan 31, 2003
Messages
54
How to create time-limiting feature (trial period)

I am a programming novice in the process of developing a simple "job-tracking" application (in Access 2002) for a home-remodeling contractor. I would like the simplest way to to implement a time-limiting feature (e.g., a trial period)...How to do?...Also, my VBA skills are virtually null, and this will be used in a shared network.
Thanks for any help offered.
 
Last edited:
Simplest way I would do it is:

Create a macro called autoexec.
Make the macro's operation to RunCode with the function name property being TimeTrial()

Create a table with two fields and only one record.

Create a new module and put this code.

Code:
Option Explicit
Option Compare Database

Public datTrialDate as Date, intDays as Integer

Function TimeTrial()

   Dim db as Database, rs as Recordset
   Set db = CurrentDb
   Set rs = db.OpenRecordset("tblTimeTrial")
   If rs.Fields("Days") = 25 Then
      Msgbox "Your trial period has expired. Please register this database.", vbCritical, "Time Trial Example"
      DoCmd.Quit
   Else
      If rs.Fields("Trial Date") <> Date() Then
         rs.Edit
         rs.Fields("Days") = rs.Fields("Days") + 1
         rs.Fields("Trial Date") = Date()
         rs.Update
       End If
   End If

End Function

This idea would give a trial date of 25 days - although those 25 days would only include those days i which the database was opened/used.

Hopefully this will give you a start, or an idea!
 
Not working...I'm sure its me...
I get a compile error of "User-defined type not defined." and the "db As Database" part of the code is highlighted by the debugger.

Here is the actual code used:

Function TimeTrial()
Dim db As Database, rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblTimeTrial")
If rs.Fields("Days") = 25 Then
MsgBox "Please see your Database Administrator", vbCritical, "Time-out"
DoCmd.Quit
Else
If rs.Fields("TrialDate") <> Date Then
rs.Edit
rs.Fields("Days") = rs.Fields("Days") + 1
rs.Fields("TrialDate") = Date
rs.Update
End If
End Function

Let me say that the "Database" Dim did not "auto-select" as an option (could this be the prob??)

thanks for the help!
 
mergle,

You have a references problem.

In the code window, choose

Tools --> References

and make sure the one for DAO is checked.

Wayne
 

Users who are viewing this thread

Back
Top Bottom