+ Reply to Thread
Results 1 to 5 of 5

How to open Access recordset via Query in Excel VBA???

Hybrid View

Guest How to open Access recordset... 03-28-2006, 12:40 AM
Guest Re: How to open Access... 03-28-2006, 01:35 AM
Guest Re: How to open Access... 03-28-2006, 04:30 AM
Guest Re: How to open Access... 03-29-2006, 09:50 AM
Guest Re: How to open Access... 03-29-2006, 03:15 PM
  1. #1
    Hexman
    Guest

    How to open Access recordset via Query in Excel VBA???

    Hello,

    Trying to write a small app and hit a wall. I have an Access DB with
    a table named PPX. I have a query named 'SortPPX' stored in Access
    which does nothing more that do a simple sort on 3 fields and a
    selection of records.

    My code, posted below fails on the 'Set rstIn.....' line with invalid
    argument.

    Is this the way you access a table via querydef? What am I doing
    wrong?

    Thanks,

    Hexman

    --------------------------------------------------------------------------------------------------------------------------
    Dim db As Database
    Dim rstIn As Recordset
    Dim rstOut As Recordset

    Dim SVTrn As String
    Dim SVSur As String
    Dim SVClass As String


    SVTrn = ""
    SVSur = ""
    SVClass = ""

    Set db = OpenDatabase("I:\Workit.mdb")
    Set rstIn = db.OpenRecordset("SortPPX", dbOpenSnapshot, _
    dbSQLPassThrough, dbReadOnly)
    Set rstOut = db.OpenRecordset("CLParLnk")

    rstIn.MoveFirst
    '
    ' Rest of code follows.........
    ---------------------------------------------------------------------------------------------------------------------------

  2. #2
    Kletcho
    Guest

    Re: How to open Access recordset via Query in Excel VBA???

    Try it without all the extras (also recordsets don't work with action
    queries):

    Set rstIn = db.OpenRecordset("SortPPX")

    or put the SQL directly in the openrecordset statement:

    Set rstIn = db.OpenRecordset("Select SuzieQs from Hostess Where Ding
    Dongs = 'Yummy!'")


  3. #3
    Hexman
    Guest

    Re: How to open Access recordset via Query in Excel VBA???

    Thanks. That worked fine. Do you know why my statement didn't work?
    I thought I read the documentation correctly.

    Hexman

    On 27 Mar 2006 21:29:03 -0800, "Kletcho" <kletcho@gmail.com> wrote:

    >Try it without all the extras (also recordsets don't work with action
    >queries):
    >
    >Set rstIn = db.OpenRecordset("SortPPX")
    >
    >or put the SQL directly in the openrecordset statement:
    >
    >Set rstIn = db.OpenRecordset("Select SuzieQs from Hostess Where Ding
    >Dongs = 'Yummy!'")


  4. #4
    Kletcho
    Guest

    Re: How to open Access recordset via Query in Excel VBA???

    You needed values for each of those properties instead of the name of
    the property.

    Set rstIn = db.OpenRecordset("SortPPX", dbOpenSnapshot,
    dbSQLPassThrough, dbReadOnly) should have read
    Set rstIn = db.OpenRecordset("SortPPX", True, False, False) or
    whatever it is you wanted for those properties. They are optional
    though and most times you don't need them.


  5. #5
    Hexman
    Guest

    Re: How to open Access recordset via Query in Excel VBA???

    I thought those were ENUM's.

    Hexman

    On 29 Mar 2006 05:44:01 -0800, "Kletcho" <kletcho@gmail.com> wrote:

    >You needed values for each of those properties instead of the name of
    >the property.
    >
    >Set rstIn = db.OpenRecordset("SortPPX", dbOpenSnapshot,
    >dbSQLPassThrough, dbReadOnly) should have read
    >Set rstIn = db.OpenRecordset("SortPPX", True, False, False) or
    >whatever it is you wanted for those properties. They are optional
    >though and most times you don't need them.


+ 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