473,785 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d ll" Alias
"GetUserNam eA" (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(str Buffer, 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.ActiveConne ction = CurrentProject. Connection
cmd.CommandType = adCmdText

cmd.CommandText = strSQL
strSQL = "INSERT INTO UserLog(UserNam e,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.ActiveConne ction = CurrentProject. Connection line

Apr 30 '07 #1
4 4285
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.ActiveConne ction = CurrentProject. Connection
cmd.CommandType = adCmdText

cmd.CommandText = strSQL
strSQL = "INSERT INTO UserLog(UserNam e,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().Exe cute "INSERT INTO UserLog(UserNam e,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.ActiveConne ction = 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****@wideope nwest.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.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.d ll" Alias
"GetUserNam eA" (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(str Buffer, 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.ActiveConne ction = CurrentProject. Connection
cmd.CommandType = adCmdText

cmd.CommandText = strSQL
strSQL = "INSERT INTO UserLog(UserNam e,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.ActiveConne ction = CurrentProject. Connection line

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

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.qu erydefs("myQuer y")
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.ActiveConn ection = CurrentProject. Connection
cmd.CommandTyp e = adCmdText

cmd.CommandTex t = strSQL
strSQL = "INSERT INTO UserLog(UserNam e,WhenUsed) " & _
"VALUES(""" & GetUser() & """,#" & _
Format(Now() , "mm/dd/yyyy hh:nn:ss") & "#)"
cmd.CommandTex t = strSQL
cmd.Execute

. . . with the following lines of code:

' On Open of my switchboard
CurrentDb().Ex ecute "INSERT INTO UserLog(UserNam e,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.ActiveConn ection = 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.orgZE RO_SPAM>
wrote in message <13************ *@corp.supernew s.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.orgZE RO_SPAM>
wrote in message <13************ *@corp.supernew s.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
9312
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 trying to instantiate the com object. This object runs fine in another asp application on the same box, so it is not the object itself. I am remotely compiling the application on our staging server. The full error message is below.
0
2479
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 exceptions on various part. I have tried both AppendChunk and using a stream object. Unfortunately all the examples I can find in the Net and on the Microsoft site
5
29848
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 Long) As Boolean Dim rsAssignedUser As ADODB.Recordset Dim strSelectUser As String
0
3285
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 for example). When I try to set the connection property or try to open a recordset using the Command object I've got an error. Here is the mehotd code for the connection set error:
0
4679
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 allways different count of rows. If anybody knows something about this kind of problem, I would appreciate any help. Thx.
0
3538
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 original question, the subject line is: ADODB.NET and "Access Denied" I have an ASP.NET page writtein in VB that uses ADODB. I just had to
4
5511
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 Server};Server=4P-12.Leighton.local;Database=HD;Uid=l0073;Pwd=cheese");
3
6106
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 ADODB.recordset rs.open "SELECT * FROM ITEM",CurrentProject.Connection, adOpenStatic, adLockOptimistic
7
4153
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;" ADODB.Connection conn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); string connString =string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", mdbFile); string query = "Select * from Client";
6
5174
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 have created an ADODB.Recordset in the reports OPEN event, built the necessary records inside of it, and then bound the report to this newly created recordset. Here's the rub:
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.