Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have a real time log of access database open & closes!

Status
Not open for further replies.

UKmedia

Programmer
Nov 2, 2002
90
I want to log the username, Machine Name, Time and Data of when the database was accessed in a table.

Any Ideas?????? UKmedia productions
 
I would add 1 additional field, the name of the database. That way, you can use the table for other projects.

With this information, you can keep track of your databases. This is how I handle it. When the database is run it checks to see if I'm the user. If I'm the user then it checks to see if the project (database) is registered. If it has not been registered, then a pop-up form is displayed asking me to enter information about the database (i.e. the default path of the front-end, the path of the back-end database, the name of the front and back-end databases, a memo field to document the purpose of the database, revisions to the database, etc). This way I'm forced to document the database.

In addition, the first time a database is run on a machine, I pop-up a form to register the computer. The information I ask is who the primary user is and their phone number. That way if I have to shut the database down or something I know who to contact.

Also, the first time a user accesses the database, I pop-up a form to register the user. Some of the information included in this form might be: the user's name, phone number, and preferences.

To get the name of the current user, use: CurrentUser
To get the time and date: Now()

The following function will return the name of the computer.


Public Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal buffer As String, ByRef nsize As Long) As Boolean

Function RetrunComputerName() As String

'********************************
'* Declaration Specifications *
'********************************

Const MAXCHAR As Integer = 50 'Max. no. of chars. in computer name

Dim i As Integer 'Loop counter
Dim strHost As String 'Name of computer returned by function

'*****************************************************************************************
'* Get the name of the computer *
'* *
'* NOTE: All Windows API calls, except those dealing directly with COM, user LPSTRs. *
'* DLLs cannot change the size of an LPSTR string once it has been created. *
'* Consequently, the string passed to the DLL needs to be big enough to accept *
'* the data to be returned before you pass it to the DLL. This is the reason *
'* why I fill the string below with enough characters to create a buffer for the *
'* DLL to fill in. I filled it with Asc 0 because this value cannot be entered *
'* via the keyboard. Therefore, a ComputerName should not contain an Asc 0. *
'*****************************************************************************************

strHost = String(MAXCHAR, 0)
GetComputerName strHost, MAXCHAR

'******************************************************************************
'* Return the name of the computer to the caller (minus the Asc 0 code(s)). *
'******************************************************************************

For i = 1 To MAXCHAR

If (Asc(Mid(strHost, i, 1)) = 0) Then

If (i = 1) Then
ReturnComputerName = vbNullString
Else
ReturnComputerName = Mid(strHost, 1, i - 1)
End If

Exit Function

End If

Next i


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top