473,408 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

ADODB using 97

T
--------------------------------------------------------------------------------

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

Apr 30 '07 #1
4 4245
Hi.
I assume the ADODB is the problem?
Yes. The ADODB library was introduced in Access 2000. However, you can
replace all of the following code:
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
.. . . with the following lines of code:

' On Open of my switchboard
CurrentDb().Execute "INSERT INTO UserLog(UserName,WhenUsed) " & _
"VALUES(""" & GetUser() & """,#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & "#)", dbFailOnError
I did try adding in Microsoft Active X 2.0 then the error moved to
cmd.ActiveConnection = CurrentProject.Connection line
You don't need the ActiveX library for this code. Remove that reference
library and recompile the code.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"T" <te****@wideopenwest.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
--------------------------------------------------------------------------------

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

Apr 30 '07 #2
On Mon, 30 Apr 2007 14:16:28 -0700, "'69 Camaro"
<Fo**************************@Spameater.orgZERO_SP AMwrote:

Or alternatively, you create a parameterized Append query in Access:
PARAMETERS parUserName text, parWhenUsed DateTime;
INSERT INTO UserLog( UserName, WhenUsed )
SELECT [parUserName] AS Expr1, [parWhenUsed] AS Expr2;

Then call it using this code:
dim qd as dao.querydef
set qd=currentdb.querydefs("myQuery")
qd!parUserName = GetUser()
qd!parWhenUsed = Now 'No need to format a date field
qd.execute dbFailOnError

parUserName and parWhenUsed are query parameters you specify under
menu option Query Parameters.

-Tom.

>Hi.
>I assume the ADODB is the problem?

Yes. The ADODB library was introduced in Access 2000. However, you can
replace all of the following code:
>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

. . . with the following lines of code:

' On Open of my switchboard
CurrentDb().Execute "INSERT INTO UserLog(UserName,WhenUsed) " & _
"VALUES(""" & GetUser() & """,#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & "#)", dbFailOnError
>I did try adding in Microsoft Active X 2.0 then the error moved to
cmd.ActiveConnection = CurrentProject.Connection line

You don't need the ActiveX library for this code. Remove that reference
library and recompile the code.

HTH.
Gunny
<clip>
May 1 '07 #3
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM>
wrote in message <13*************@corp.supernews.com>:
Hi.
>I assume the ADODB is the problem?

Yes. The ADODB library was introduced in Access 2000.
I don't think the ADO library is the problem, except that it seems
the errormessage indicates there's no reference to the library.

ADO is a separate library that can be referenced and used in Access 97.

Here, the next problem would be the CurrentProject.Connection, which
isn't part of ADO, but Access. That property wasn't added to Access
until the the 2000 version, which makes using the current database
in Access 97 a bit awkward ;-)

Danny Lesandrini demonstrates the principles of how it can be done here
http://groups.google.com/group/comp....5d794acd89ffa/

--
Roy-Vidar
May 1 '07 #4
Hi, Roy-Vidar.
I don't think the ADO library is the problem
The error message that the user-defined type wasn't defined was due to the
fact that he didn't have the ADODB library referenced, and he truly didn't
need to have it referenced for Access 97, because the default libraries
easily handled the task he needed to do. That's why I agreed that the ADODB
library was his problem.
ADO is a separate library that can be referenced and used in Access 97.
Yes. It can be. And DAO 3.6 can also be referenced in Access 97, along
with other libraries for later versions of Office applications. But just
because one can reference those libraries and the code compiles doesn't mean
that one should do so. Access 97 wasn't designed to work with those
versions of the libraries. Screwy things can happen when the wrong library
or the wrong version of a library is used, so it's not recommended. As an
extreme example, look at what happens when Access 2000 without SP-3
references the VBA 6.2 or 6.4 library from Office XP or Office 2003, and the
code compiles at runtime. The code project corrupts.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"RoyVidar" <ro*************@yahoo.nowrote in message
news:mn***********************@yahoo.no...
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM>
wrote in message <13*************@corp.supernews.com>:
>Hi.
>>I assume the ADODB is the problem?

Yes. The ADODB library was introduced in Access 2000.

I don't think the ADO library is the problem, except that it seems
the errormessage indicates there's no reference to the library.

ADO is a separate library that can be referenced and used in Access 97.

Here, the next problem would be the CurrentProject.Connection, which
isn't part of ADO, but Access. That property wasn't added to Access
until the the 2000 version, which makes using the current database
in Access 97 a bit awkward ;-)

Danny Lesandrini demonstrates the principles of how it can be done here
http://groups.google.com/group/comp....5d794acd89ffa/

--
Roy-Vidar


May 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KLomax | last post by:
I have a VB6 com object that uses ADO 2.1 for data access. I have referenced this object in a aspx application. It works fine on my local development machine. On our staging server, it errors when...
0
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
0
by: Andre Azevedo | last post by:
Hi all ! I've created a .net serviced component with only one method. This method receive an ADODB.Command object and execute it. The ADODB.Command object is created in the client process. (VB...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
4
by: Ames111 | last post by:
Hi I have an application that connects to a SQl database on my computer via an ADODB connection: ADODB.Connection Conn = new ADODB.Connection(); Conn.ConnectionString = ("Driver={SQL...
3
by: mark_aok | last post by:
Hi all, All I am trying to do is open a table, edit it, and then close it. But I am having the strangest error. Here is my code Dim i as integer Dim rs as adodb.recordset Set rs = new...
7
by: Bryan | last post by:
Hi , I am using ADO (ADODB) with access database. Not sure what I am doing wrong.here. Can anyone please help me? string mdbFile = System.IO.Directory.GetCurrentDirectory() +" \\bTrack.mdb;"...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.