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).]
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