Consulting

Results 1 to 5 of 5

Thread: Querying Access from Excel using VBA

  1. #1

    Querying Access from Excel using VBA

    I am trying to query Access from Excel using VBA. I am getting a compile error that says Named Argument not found. Below is the code I am using. Any help would be great...i am totally stuck.
    thanks.

    Dim db As Database
    Dim Qd As QueryDef
    Dim rs As Recordset
    Dim Ws As Object
    Dim i As Integer
    Dim Path As String

    Path = "H:\PJM_FTR_Pricing\Pricing_FTR_TCR_1.mdb"

    Set Ws = Sheets("Results")

    Ws.Activate
    Range("A1").Activate
    Range("Pricing_FTR_TCR_1").Select
    Selection.ClearContents

    (***THIS IS WHERE THE ERROR RESIDES - SPECIFICALLY WITH EXCLUSIVE:=FALSE***))

    Set db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True, _
    Exclusive:=False)

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Try Options:=False instead of Exclusive:=False
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    Hi Tony,
    thanks, but now I get another error stating AcitveXComponent can't create object.

  4. #4
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    I would guess that's because you are trying to use a Workspace that you haven't created.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  5. #5
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Is the error on the same line?
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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