View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
roger roger is offline
external usenet poster
 
Posts: 16
Default Using excel to access MS Access saved query

"matelot" wrote in message
...
I use the following code to open Access db and run a sql.
set dbs=opendatabase(dbname)


You don't need the next two lines, which are for creating a new query

set qry= dbs.createquerydef("queryname")
qry.sql="select name from customers"


use this instead -

set qry= dbs.querydefs("queryname")

set rst = qry.openrecordset()
Activesheet.range("A1").copyfromrecordset rst

It's working fine. However, I have multiple saved queries in MS Access

that
I would like to access from Excel VBA. I tried replacing "queryname" to

the
saved query name and it's not working. Am I missing something?



--
roger