connection acess database
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Connection to an acess database

Connection to an acess database

resolvedResolved · High Priority · Version 2007

replyReply Wed 18 Nov 2009, 14:59Delegate jeff said...

jeff has attended:
Excel VBA Intro Intermediate course

Connection to an acess database

I am trying to connect to an access database. I have successfully created the udl and tested its connection but have fallen at the next hurdle. When I try to run my script it errors on the line "Dim cnConnection As ADoDB.connnection" with Compile error: User-defined type not defined. The script up to the point it fails is shown below:

Sub ImportAmbients()
'18/11/09 JCalam Scrip to import the ambient contitions from the balance database.

Const ConString As String = _
"Provider=MSDASQL.1;Password=buttman;Persist Security Info=True;Data Source=BalanceData;Mode=Read;Initial Catalog=C:\BalBase\Bal32Base"

Dim cnConnection As ADODB.Connection

'I am pretty sure it is related to be not having the required add in or dll installed. When we did out course we had to enable and add in or option. Any help would be greatly appreciated.

Jeff

For upcoming training course dates see: Pricing & availability

replyReply Thu 19 Nov 2009, 11:33Trainer Stephen said...

RE: Connection to an acess database

Hi Jeff

Thanks for your question

You need to set a reference to the activeX data objects library.

In the VBE click on Tools , References

You will see a list of possible references, with the ones currently set having a tick against them. If "active x dataobjects 2.8 library" is not ticked, you will need to scroll down until you find it and tick it. (Note the number 2.8 may differ on your machine, if it does choose the nearest matching number)

If this do9esn't solve the problem please get back to me

Regards

Stephen

 

Please browse our web site to find out more about
excel computer training london and other Microsoft training courses.

Excel tip:

Create and delete borders

To put a border around the outside of a selected range, press Ctrl+Shift+&. Use Ctrl+Shift+_ (underscore) to remove any borders from a range.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard