p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: ADODB error on form


Message #1 by "Chris Dailey" <cdailey@u...> on Wed, 5 Jun 2002 15:50:09
I was just sent a piece of code from one of the programmers here.  I use 
similar code all of the time with no problems, but in his database it 
gives an error.  Here is the code:

Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  Dim Class As String
  Dim store As String
  Dim cnn As ADODB.Connection         <--ERROR OCCURS HERE
  Set cnn = CurrentProject.Connection
  Dim StrTable1, StrTable2 As String
  StrTable1 = "Select * From [Days and Times] Where [Class Key] = Class;"
  Set rst1 = New ADODB.Recordset
  
   
If Me![Combo33] = "Management Development" Then
    Class = Me![class-key]
    store = Me![Combo26]
    
  rst.Open Source:=StrTable1, Activeconnection:=cnn, 
Cursortype:=adOpenKeyset, LockType:=adlockpessimistic
   
End If
    
    
End If

End Sub

When I try to compile the code, I get the following error:
"User defined type not defined"

I'm guessing it is something stupid like the alignment of the planets, but 
if you have any ideas, please let me know.

Thanks,
Chris
Message #2 by "Carnley, Dave" <dcarnley@a...> on Wed, 5 Jun 2002 09:50:16 -0500
you need to set a reference to ADO.  From the VBE go to Tools->References
and check the box for ADO -   "Microsoft ActiveX Data Objects 2.1 Library"


-----Original Message-----
From: Chris Dailey [mailto:cdailey@u...]
Sent: Wednesday, June 05, 2002 10:50 AM
To: Access
Subject: [access] ADODB error on form


I was just sent a piece of code from one of the programmers here.  I use 
similar code all of the time with no problems, but in his database it 
gives an error.  Here is the code:

Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  Dim Class As String
  Dim store As String
  Dim cnn As ADODB.Connection         <--ERROR OCCURS HERE
  Set cnn = CurrentProject.Connection
  Dim StrTable1, StrTable2 As String
  StrTable1 = "Select * From [Days and Times] Where [Class Key] = Class;"
  Set rst1 = New ADODB.Recordset
  
   
If Me![Combo33] = "Management Development" Then
    Class = Me![class-key]
    store = Me![Combo26]
    
  rst.Open Source:=StrTable1, Activeconnection:=cnn, 
Cursortype:=adOpenKeyset, LockType:=adlockpessimistic
   
End If
    
    
End If

End Sub

When I try to compile the code, I get the following error:
"User defined type not defined"

I'm guessing it is something stupid like the alignment of the planets, but 
if you have any ideas, please let me know.

Thanks,
Chris
Message #3 by joe.dunn@c... on Wed, 5 Jun 2002 16:06:44 +0000
Check your references - open a module in design mode and go to tools /
references. You must have a library like

Microsoft ActiveX Data Objects 2.1 library
Microsoft ActiveX Data Objects Recordset 2.5 library

ticked for VBA to be able to use the library.

There are a lot of reference in P2pwrox.com - search under an Access VBA
forum and look for 'references'

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named
recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return:
you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an
authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions
expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Financial Services Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965  - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS
name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail
cis@c...

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number
990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the
Bank.

CIS is a member of the General Insurance Standards Council

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************
Message #4 by "Chris Dailey" <cdailey@u...> on Wed, 5 Jun 2002 21:04:12
Thanks everyone - It works fine now.
Message #5 by "Leo Scott" <leoscott@c...> on Wed, 5 Jun 2002 13:00:35 -0700
Just as a side note, I hope you are not leaving your controls named Combo33.
In the long run that will make code maintainence very difficult.

snip
Private Sub Combo33_BeforeUpdate(Cancel As Integer)
  Dim Class As String

|-----Original Message-----
|From: Chris Dailey [mailto:cdailey@u...]
|Sent: Wednesday, June 05, 2002 9:04 PM
|To: Access
|Subject: [access] Re: ADODB error on form
|
|
|Thanks everyone - It works fine now.
|


  Return to Index