Writing username to table onOpen and onClose in a form
Hi.
I am trying to make a log of all the different forms in my db. It is for statistical usage only, to se which forms that are often used, and which forms who are never used.
Allen Brown has a great audit trail, but I cannot implement because I have a tekstfield as a primary key.
I need a module to write "open" or "close", username, formname and Now() to a table, and I need help on how to do this.
The tablename is: tblFormLog with the fields "LogID" primary key autonumber , "Type" text, ,"User" text, "logTime" date/time and "formName" text).
So far I have taken some bits form Allen Browns Audit code, but havent managed to make it work.
To get the username I use the code from Brown:
Now I need a function to write to the table on the forms OnOpen and OnClose.
How do I form the Sql from here, and how do I implement to "capture" the forms name?
Can anyone help on this one?
Hi.
I am trying to make a log of all the different forms in my db. It is for statistical usage only, to se which forms that are often used, and which forms who are never used.
Allen Brown has a great audit trail, but I cannot implement because I have a tekstfield as a primary key.
I need a module to write "open" or "close", username, formname and Now() to a table, and I need help on how to do this.
The tablename is: tblFormLog with the fields "LogID" primary key autonumber , "Type" text, ,"User" text, "logTime" date/time and "formName" text).
So far I have taken some bits form Allen Browns Audit code, but havent managed to make it work.
To get the username I use the code from Brown:
Code:
Function NetworkUserName() As String
'Purpose: Returns the network login name
Dim lngLen As Long
Dim lngX As Long
Dim strUserName As String
NetworkUserName = "Unknown"
User = String$(254, 0)
lngLen = 255&
lngX = apiGetUserName(strUsername, lngLen)
If (lngX > 0&) Then
NetworkUserName = Left$(strUserName, lngLen - 1&)
End If
End Function
Now I need a function to write to the table on the forms OnOpen and OnClose.
How do I form the Sql from here, and how do I implement to "capture" the forms name?
Can anyone help on this one?
Last edited: