View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hexman Hexman is offline
external usenet poster
 
Posts: 13
Default 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.........
---------------------------------------------------------------------------------------------------------------------------