Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Using excel to access MS Access saved query

I use the following code to open Access db and run a sql.
set dbs=opendatabase(dbname)
set qry= dbs.createquerydef("queryname")
qry.sql="select name from customers"
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?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query from Access into Excel cause Access to go to read only T Stephens Excel Discussion (Misc queries) 0 March 24th 09 04:17 PM
Excel 2007 Quick Access Toolbar Changes not Saved den4673 Excel Discussion (Misc queries) 1 April 17th 07 02:21 PM
Can I use MS Query in Excel like an Append Query in Access Sam Wardill Excel Discussion (Misc queries) 0 April 11th 06 02:41 PM
Run Access query from Excel, input value to query being value in c Nagesh Excel Programming 3 December 22nd 05 02:00 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"