I tried this audit trail code, using 2003 and it works great, I try and use it at work w/97 and it blows up:
Compile error, user defined type not defined
I assume the ADODB is the problem? How would I change / fix this to work w/97
Table called UserLog
w/field UserName txt
WhenUsed date & time
module
Option Compare Database
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long
Public Function GetUser() As String
Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long
lngSize = 199
strBuffer = String$(200, 0)
lngRetVal = GetUserName(strBuffer, lngSize)
GetUser = Left$(strBuffer, lngSize - 1)
End Function
'module ends'
On Open of my switchboard
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
strSQL = "INSERT INTO UserLog(UserName,WhenUsed) " & _
"VALUES(""" & GetUser() & """,#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & "#)"
cmd.CommandText = strSQL
cmd.Execute
Any help would be greatly appreciated...I'm a hack at best
Compile error, user defined type not defined
I assume the ADODB is the problem? How would I change / fix this to work w/97
Table called UserLog
w/field UserName txt
WhenUsed date & time
module
Option Compare Database
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long
Public Function GetUser() As String
Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long
lngSize = 199
strBuffer = String$(200, 0)
lngRetVal = GetUserName(strBuffer, lngSize)
GetUser = Left$(strBuffer, lngSize - 1)
End Function
'module ends'
On Open of my switchboard
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
strSQL = "INSERT INTO UserLog(UserName,WhenUsed) " & _
"VALUES(""" & GetUser() & """,#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & "#)"
cmd.CommandText = strSQL
cmd.Execute
Any help would be greatly appreciated...I'm a hack at best