# Connecting to Access from Excel

#### hianupam

##### New Member
I am trying to connect to access and when I define a connection object like

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

What am I doing wrong ?

### Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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!!!

I hate to sound like an idiot but how do I do this and where

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
Hey there is a hole in my math.

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

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

You can always set the reference programatically;

<pre/>

'// 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!
On Error Resume Next
Set ID = ThisWorkbook.VBProject.References

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

Replies
1
Views
93
Replies
2
Views
181
Replies
1
Views
315
Replies
13
Views
275
Replies
0
Views
342

1,220,965
Messages
6,157,122
Members
451,399
Latest member
alchavar

### 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.

### Which adblocker are you using?

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

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