Solved

Microsoft Dao 3.6 Object Library ,Microsoft ActiveX Data Object 2.8 Library Reference Issues

Posted on 2010-11-30
4
946 Views
Last Modified: 2012-05-10
In my Visual Basic Project, I have added the references,

1.      Microsoft Dao 3.6 Object Library
2.      Microsoft ActiveX Data Object 2.8 Library – newly added reference and the below piece of code:

I am using MS Office 2000

    Const DataProvider As String = "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;"
   
    Dim adoPrimaryRS As Recordset
    Dim db      As ADODB.Connection

    'Execute the query.
     Set adoPrimaryRS = New ADODB.Recordset
    src = sql()
    ADODB.adoPrimaryRS.Open src, db, adOpenDynamic, adLockOptimistic


Error - adoPrimaryRS - Method or Data memebr not found.

If I change the order of the reference, then the above code is working. but the existing code is not working.

It seems both  above reference have conflict.
0
Comment
Question by:bobbey
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 34240760
Hi

You are getting the Error - adoPrimaryRS - Method or Data memebr not found, beacuse you are adding ADODB to your adoPromaryRS object in this line

  ADODB.adoPrimaryRS.Open src, db, adOpenDynamic, adLockOptimistic

You should use it like this

adoPrimaryRS.Open src, db, adOpenDynamic, adLockOptimistic
0
 

Author Comment

by:bobbey
ID: 34240943
now the error become,
.Open method  or data memebr not found.

I couldn't find the method Open after putting the ".".

if I change  reference order like

1.  Microsoft ActiveX Data Object 2.8 Library
2. Microsoft Dao 3.6 Object Library

adoPrimaryRS.Open src, db, adOpenDynamic, adLockOptimistic

the above  code works
0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 34241000
Ok, you do not need to change the reference order, just add ADODB  to your object declaration like this

Dim adoPrimaryRS As ADODB.Recordset

This happend because DAO and ADO both have a Recordset type object, so you have to specify wich one you are trying to use.
0
 

Author Closing Comment

by:bobbey
ID: 34241024
I spend 4 hours for this. thank you so much
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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