98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel Training and help » Connection to an acess database
Connection to an acess database
Resolved · High Priority · Version 2007
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
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
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Select only cell that contain text to lock formatFor selecting cells that only contain Text in Excel |