Capture of First Use Date

  • Thread starter Thread starter Tony Uythoven
  • Start date Start date
T

Tony Uythoven

I am distributing my application and it is important to me to capture and
store the date the program is first opened on another computer. How can
this be done?

Thanks,
Tony
 
Where do you want to store it? If on your network create a
table with computer name, UserId and date opened. Index
all three fields with no duplicates. When opening the form
on the remote pc's check to see if that machine has been
entered in the table. if not, run an append query for that
computername userid and date opened.

Chris
 
I would put the code in a logo form that is shown at startup. To have a form
run at startup goto Tools then Startup and set the Display Form/Page dropdown
to your splash screen.

Good Luck!
 
The key question I have is: How do you capture the date that the database
was opened the first time and then store this date in the database for
future usage?

Tony
 
If you store the data in an external source, such as the registry or an INI
file, then if it isn't there, this is the first time.

See the GetSetting and SaveSetting functions in the (VBA) help file for
examples of how to store and retrieve a setting in the registry.
 
Hi Tony,

Well there are almost an endless amount of ways to do this.
Brendan already suggested using registry or INI entries.

Here is another alternative done completely within the database.

1. Create a new table called tblInstallDate with one field
DateInstalled - Date/Time
Set it as the Primary Key.

2. In the open event of your main switchboard-type form
enter this code:

'***********Code Start************
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

If DCount("DateInstalled", "tblInstallDate") = 0 Then
' First time use, record the date and time
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblInstallDate")
With rst
.AddNew
.Fields("DateInstalled") = Now()
.Update
End With
End If

ExitPoint:
' Cleanup Code
On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'***********Code Start************

3. If you are using Access 2000 or 2002 make sure to
set a reference to the DAO object library.

4. Compile the code, save and close the form.

5. Under Tools | Startup make sure this form is set
to open when the database opens.

6. Now close the database and then re-open to test.
If there is no record in the table, a new record is silently
created when the main form opens. This will date stamp
the first time the application is used.

You will of course need to ship the application with the
table empty. This method is certainly not fool-proof by
any means, but you could make it much more difficult
to change by implementing User Level Security and then
disabling the Shift key bypass.

You could add additional fields to the table and record other
information as well such as user, computer name, etc.
It all depends on how sophisticated you want to get.
You can simply use this table information elsewhere
within the application.

Hope that gives you some ideas.
 
Back
Top