Is there a way to tell how many times a database is open by the user (1 Viewer)

reena

Registered User.
Local time
Today, 13:31
Joined
Jul 18, 2001
Messages
17
Is there a way to tell how many times a database is open by the user.

Thanks I am looking for a way to code desperately.

Thanks in advance
 

doulostheou

Registered User.
Local time
Today, 07:31
Joined
Feb 8, 2002
Messages
314
I would think all you would have to do is create a table that stores the information (we'll call the field Opened)

Put the following code in the startup form:

Opened = Opened + 1

It will then increase by one each time the database is opened.

If your database is on a network and you are wanting to get this information for each user, this would obviously need to become more complicated. But it can still be done by adding each user to the table and using the Docmd.FindRecord function to update for the appropriate user.

[This message has been edited by doulostheou (edited 04-26-2002).]
 

jatfill

Registered User.
Local time
Today, 08:31
Joined
Jun 4, 2001
Messages
150
This may not be the easiest way of accomplishing this, but I would probably try something like the following:

Create a table with two fields called "tblAccess", name the fields "rec" (text)and "accesscount" (number). Create a single record in the table with the "rec" field value of "primary."
On startup, if you have an existing form that automatically opens, put this code in the OnOpen event of the form. If you do not have a form that automatically opens, create one called "frmStartup" and add the following code behind the form:

Code:
Private Sub Form_Open(Cancel As Integer)

If IsNull(DLookup("[accesscount]", "tblAccess", "[rec] = 'primary'")) Then
    DoCmd.Close acForm, "frmStartup"
    DoCmd.SetWarnings False
    DoCmd.RunSQL "Update tblAccess " & _
            "Set accesscount = 1" & " " & _
            "Where rec = 'primary'"

    DoCmd.SetWarnings True
    Exit Sub
Else

    Dim NewCount As Integer
        NewCount = DLookup("[accesscount]", "tblAccess", "[rec] = 'primary'") + 1

    DoCmd.Close acForm, "frmStartup"
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "Update tblAccess " & _
            "Set accesscount = " & NewCount & " " & _
            "Where rec = 'primary'"

    DoCmd.SetWarnings True
    Exit Sub
End If
    

End Sub

Then just set the startup form to load every time the DB is opened, and the accesscount field will be incremented by one each time the database is opened.

This may be an odd way of looking at it... honestly the reason I would do it this way is so I could create an access list based on the users, I generally do user-level security so you could use the rec field to store the user name & add all kinds of statistics (last logged in date, average session time, etc.) to the tblAccess table.

So this iss the simplified version... I hope it works for you
 

Travis

Registered User.
Local time
Today, 05:31
Joined
Dec 17, 1999
Messages
1,332
You could always try to view this information with the ldb file reader Microsoft has somewhere on its web site.
 

reena

Registered User.
Local time
Today, 13:31
Joined
Jul 18, 2001
Messages
17
Thanks for your suggestions everybody. I'll try and let you know my results.

Thanks once again.
 

reena

Registered User.
Local time
Today, 13:31
Joined
Jul 18, 2001
Messages
17
Thanks jetfill,

your post was really helpful thanks again.
 

Users who are viewing this thread

Top Bottom