Solved

MS VBA AODBC Run-time Error

Posted on 2007-03-26
4
368 Views
Last Modified: 2013-12-25
I'm trying to use the Microsoft ActiveX Data Objects 2.8 Library to establish a connection to a Sybase database.  I have successfully used the XLODBC.XLA driver on the same computer, so I believe the ODBC connection is set up properly.  This is using Excel 2000 and Windows 2000 Professional.

I am getting the following error when I try to set the connection:
     Run-time error '-2147024769 (8007007f)':
     Automation error
     The specified procedure could not be found.

However, the library is selected in the VBA References list.  Here is my code; the error is generated on line 13 (commented accordingly):

     Sub testSQL()

     Dim uidA, pwdA As String
     dsnA = InputBox("Data Server Name:")
     uidA = InputBox("DB User ID:")
     pwdA = InputBox("DB Password:")
     
     Dim conn As ADODB.Connection
     Dim connStr As String
     Dim rs As ADODB.Recordset
     
     connStr = "DSN="& dsnA & ";UID=" & uidA & ";PWD=" & pwdA & ";"
     Set conn = New ADODB.Connection     '<---- This is the line that generates the error message
     conn.Open connStr
     conn.Close
     Set conn = Nothing

     End Sub

Does anyone know what might be causing this error?  Thanks in advance for the help.
0
Comment
Question by:davidjt61983
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 500 total points
ID: 18795105
After consulting several references and finding a mishmash of ideas for solving this, I'm reduced to two suggestions:  either reinstall MDAC 2.8, or attempt to identify and re-register each and every DLL it uses.  I recommend this because it seems that while the system can find the object (otherwise you would have gotten an object not found error), the interface definitions have become corrupted somehow, so that it can't find the constructor method.

As an alternative, you can try CreateObject("ADODB.Connection") and see if it instantiates properly.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 18810075
In Excel go to your code window then Tools/References.  Is the following one of the checked items?

Microsoft ActiveX Data Objects 2.8 Library?

If it is, try unchecking, close the dialog box, then go back and check it again.  If that does not work try library 2.7

Leon
0
 

Author Comment

by:davidjt61983
ID: 18815739
Thanks for your help.

It took a day to get the package re-installed due to office policies, etc.  I am now able to establish a connection.
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 18816351
yvw :)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month3 days, 22 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question