Connecting to Access from Excel

hianupam

New Member
Joined
Mar 28, 2002
Messages
37
I am trying to connect to access and when I define a connection object like

Dim cn As ADODB.Connection

excel gives me an error like "User Defined Type Not Defined"

What am I doing wrong ?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

KniteMare

Board Regular
Joined
Mar 4, 2002
Messages
238
Set a Reference to MSDataObjects 2.0 lib

Yours in EXCELent Frustration

KiteMare


E to the X
D Y D X
E to the X
D X
Secant Tangent Cosign Sign
3.14159

Huraaaay Math!!!
 

KniteMare

Board Regular
Joined
Mar 4, 2002
Messages
238
From the VBE (where you do your code) Select Tools
References...
From the Drop Down List select
MicroSoft Activex DataObjects 2.0 lib

Check the box.

The reference will be set.

When you are using one application from another you need to set references to that applications object. You want to set as few of these as possible. This is because Excel has to look through them all for the reference. If you try to uncheck a reference that is being used you will recieve an error message. If you uncheck one that is not being used but later is needed, Same error message. The help files are not very clear on how to use these. I spent like a gagillion bucks on various books trying to learn the ins and outs. After all that I learned more here in one month of reading the posts and asking questions than I did in a year of reading. Oh well at least the books give me something to read on long airline flights when I need the sleep. :)


Yours in EXCELent Frustration

KniteMare


.9 repeating is really 1?
1/3 = .3333333(repeating)
3*3=9
so why does 3*.3333333(repeating) =1
instead of .9999999999 (repeating)
Hey there is a hole in my math.
 

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
.9 repeating is really 1?
1/3 = .3333333(repeating)
3*3=9
so why does 3*.3333333(repeating) =1
instead of .9999999999 (repeating)
Hey there is a hole in my math.

Probably related to the fact that 2 plus 2 equals 5 for large values of 2.
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
You can always set the reference programatically;

<pre/>

Sub CreateRef_Library_ADODB()
'// Set a Reference to ADODB[M].tlb
'// Microsoft ActiveX Data Objects 2.0 Library M.m Type Library
'// : Note The 1 for Major Version!
'// If it already exits Resume & Handle latter!
'// C:PROGRAM FILESCOMMON FILESSYSTEMADOmsado20.tlb
On Error Resume Next
Set ID = ThisWorkbook.VBProject.References
ID.AddFromGuid "{00000200-0000-0010-8000-00AA006D2EA4}", 1, 0

If Err.Number <> 32813 And Err.Number <> 0 Then
MsgBox "Error Number:= " & Err.Number & vbCr _
& "Error Discrp:= " & Err.Description & vbCr & vbCr & _
"[msado20.tlb] Type Library", _
vbMsgBoxHelpButton, _
"Error" & sGuid, Err.HelpFile, Err.HelpContext
End If
End Sub
</pre>
 

Forum statistics

Threads
1,144,116
Messages
5,722,568
Members
422,447
Latest member
srclife

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top