Re: Capture of First Use Date

From: Jeff Conrad (jeffc_at_ernstbrothers.com)
Date: 02/15/05


Date: Tue, 15 Feb 2005 15:19:58 -0800

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.

-- 
Jeff Conrad
Access Junkie
Bend, Oregon
"Tony Uythoven" <Tony@TonyUythoven.com> wrote in message
news:%23tmxY05EFHA.1564@TK2MSFTNGP09.phx.gbl...
> 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
>
>
>
> "Chris Reveille" <anonymous@discussions.microsoft.com> wrote in message
> news:017901c512df$f6e16220$a601280a@phx.gbl...
> > 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
> >
> > >-----Original Message-----
> > >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
> > >
> > >
> > >.
> > >
>
>


Relevant Pages

  • Re: SetOption "Default Database Directory"
    ... As I said it works except for the first time the database opens and is set ... even with the rowsource problem solved. ... Database and reopen it and the form, ...
    (microsoft.public.access.formscoding)
  • Re: Capture of First Use Date
    ... 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 ... > Where do you want to store it? ...
    (microsoft.public.access.forms)
  • Re: Get User ID
    ... You would have to store the information somewhere. ... create a hidden form that opens when the front-end is opened. ... open event, write code that stores the UserID to a ... I am wanting to have a field in my database that displays ...
    (microsoft.public.access.modulesdaovba)
  • MS access 2007 creates a copy when I close it
    ... I have a database which is located on my server in a shared company folder. ... When one of my end users opens the database and then closes it, ... The first time he ...
    (microsoft.public.access.gettingstarted)
  • Report initialization? problem.
    ... When I open a database, ... FIRST time I preview a report it appears that Access is ignoring the ... Opens fine. ...
    (microsoft.public.access.reports)