PDA

View Full Version : Querying Access from Excel using VBA



kansasmlb
11-18-2007, 03:29 PM
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)

TonyJollans
11-18-2007, 04:49 PM
Try Options:=False instead of Exclusive:=False

kansasmlb
11-18-2007, 04:57 PM
Hi Tony,
thanks, but now I get another error stating AcitveXComponent can't create object. :(

TonyJollans
11-18-2007, 05:58 PM
I would guess that's because you are trying to use a Workspace that you haven't created.

rory
11-20-2007, 07:05 AM
Is the error on the same line?