+ Reply to Thread
Results 1 to 2 of 2

Run Make table query from Excel

  1. #1
    RW
    Guest

    Run Make table query from Excel

    I need data from Access. The Access query is based on a table that must be
    created first using a Make Table query. How do I run this query from Excel
    VBA?

    I tried:
    200 Set db = OpenDatabase(Name:=strDbName1, _
    Options:=False, ReadOnly:=True)
    Set qry = db.QueryDefs(strQryName1)
    Set rs = qry.OpenRecordset(dbOpenSnapshot)
    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing

    but it fails at:
    Set rs = qry.OpenRecordset(dbOpenSnapshot)

    I can get the 2nd query to run when the table is created within Access.
    However, I need to do all of this on the Excel side.

    Thanks

  2. #2
    K Dales
    Guest

    RE: Run Make table query from Excel

    To run an Action query in DAO you should use the Execute method of the
    QueryDef, not OpenRecordset (since no recordset is opened).

    ref:
    http://msdn.microsoft.com/archive/de.../D2/S5A270.asp
    --
    - K Dales


    "RW" wrote:

    > I need data from Access. The Access query is based on a table that must be
    > created first using a Make Table query. How do I run this query from Excel
    > VBA?
    >
    > I tried:
    > 200 Set db = OpenDatabase(Name:=strDbName1, _
    > Options:=False, ReadOnly:=True)
    > Set qry = db.QueryDefs(strQryName1)
    > Set rs = qry.OpenRecordset(dbOpenSnapshot)
    > rs.Close
    > Set rs = Nothing
    > db.Close
    > Set db = Nothing
    >
    > but it fails at:
    > Set rs = qry.OpenRecordset(dbOpenSnapshot)
    >
    > I can get the 2nd query to run when the table is created within Access.
    > However, I need to do all of this on the Excel side.
    >
    > Thanks


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1