Log that a user opened a report / form

teiben

Registered User.
Local time
Today, 15:20
Joined
Jun 20, 2002
Messages
462
Help!
I established a tblLog w/fields TheUser, TheReport, OpenDateTime.
I created a module to capture the name of the user logged into the network


'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

I would prefer to count the number of times the database was opened, but I'll settle for the number of times Report1 was opened. I've been told I need an append query to run when Report1 is opened. This is my SQL, which doesn't work, then I tried creating an append query no luck.

Will this work? & what is the matter with my sql?

On Open
INSERT INTO tblLog (TheUser, Report1, OpenDateTime ) " & _ "
SELECT """ & CurrentUser() & """ AS TheUser, 'Report1' AS TheReport
 
The format is incorrect
INSERT INTO tblname (Field List) VALUES (Value List)
 

Users who are viewing this thread

Back
Top Bottom