ADODB using 97



--------------------------------------------------------------------------------

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
I did try adding in Microsoft Active X 2.0 then the error moved to
cmd.ActiveConnection = CurrentProject.Connection line

.



Relevant Pages

  • Re: Problem with saving .txt attachement
    ... Dim Inbox As MAPIFolder ... Dim strSubject As String ... Next Item 'Compile Error: ... >> for the attachement n let u know i made it. ...
    (microsoft.public.outlook.program_vba)
  • Re: Mid function compile error
    ... compile error machines and identify any MISSING references. ... Running it on another machine I get a compile error with the Mid function ... Dim firstLine As Boolean, firstSmp As Boolean, firstPlot As Boolean ... Dim fileFilter As String, Title As String, fullFileName As String, file As ...
    (microsoft.public.excel.programming)
  • Re: Mid function compile error
    ... "Tim Zych" wrote: ... Running it on another machine I get a compile error with the Mid function ... Dim firstLine As Boolean, firstSmp As Boolean, firstPlot As Boolean ... Dim fileFilter As String, Title As String, fullFileName As String, file As ...
    (microsoft.public.excel.programming)
  • Re: load a filtered form based on user login
    ... I'm getting compile error; ... Function faq_IsUserInGroup (strGroup As String, ... Dim ws As WorkSpace ... Dim strUserName as string ...
    (microsoft.public.access.tablesdbdesign)
  • Re: capturing the computer id in a access querry
    ... SELECT colA, colB, GetComputer() As ComputerName ... "GetComputerNameA" (ByVal strBuffer As String, ... Dim strComputerName As String ... Dim lngSize As Long ...
    (microsoft.public.access.queries)