DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to open an ADO Recordset from Access VBA?

  1. #1
    Manuel De Leon Guest

    How to open an ADO Recordset from Access VBA?


    Can anyone translate this DAO code into ADO? (Im using Access VBA)
    ----------------------------
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("tblClients")
    'Some code
    rst.Close
    Set rst = Nothing
    ----------------------------

    If I declare rst as ADO.Recordset when I run the program it gives an error
    on the second line ("type mismatch")

    Thank You,


  2. #2
    Arthur Wood Guest

    Re: How to open an ADO Recordset from Access VBA?


    Manuel,
    As this appears to be MS Access, and I assume that you are using Access
    2000, then here is what you need

    1) make sure that there is a reference to ther ActiveX Data Objects Library
    3.6 (Tools/References from the VBA Code editor)

    then:

    Dim MyConnection as Connection
    Dim rst as Connection ' note-->DO NOT use DAO.Recordset

    set MyConnection = Application.CurrentProject.Connection
    set rst = New Recordset
    rst.Open "Select * from tblClients",MyConnection

  3. #3
    Sue Harsevoort Guest

    Re: How to open an ADO Recordset from Access VBA?

    I think Arthur meant

    Dim rst as Recordset

    Sue

    "Arthur Wood" <wooda@nospam.com> wrote in message
    news:3c611d73@10.1.10.29...
    >
    > Manuel,
    > As this appears to be MS Access, and I assume that you are using Access
    > 2000, then here is what you need
    >
    > 1) make sure that there is a reference to ther ActiveX Data Objects

    Library
    > 3.6 (Tools/References from the VBA Code editor)
    >
    > then:
    >
    > Dim MyConnection as Connection
    > Dim rst as Connection ' note-->DO NOT use DAO.Recordset
    >
    > set MyConnection = Application.CurrentProject.Connection
    > set rst = New Recordset
    > rst.Open "Select * from tblClients",MyConnection




  4. #4
    Paul Clement Guest

    Re: How to open an ADO Recordset from Access VBA?

    On Wed, 6 Feb 2002 11:05:57 -0500, "Sue Harsevoort" <SusannaH67@hotmail.com> wrote:

    I think Arthur meant

    Dim rst as Recordset


    Or to be on the safe (and explicit side):

    Dim rst as ADODB.Recordset


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center