Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RW RW is offline
external usenet poster
 
Posts: 49
Default Run Make table query from Excel

I need data from Access. The Access query is based on a table that must be
created first using a Make Table query. How do I run this query from Excel
VBA?

I tried:
200 Set db = OpenDatabase(Name:=strDbName1, _
Options:=False, ReadOnly:=True)
Set qry = db.QueryDefs(strQryName1)
Set rs = qry.OpenRecordset(dbOpenSnapshot)
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

but it fails at:
Set rs = qry.OpenRecordset(dbOpenSnapshot)

I can get the 2nd query to run when the table is created within Access.
However, I need to do all of this on the Excel side.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Run Make table query from Excel

To run an Action query in DAO you should use the Execute method of the
QueryDef, not OpenRecordset (since no recordset is opened).

ref:
http://msdn.microsoft.com/archive/de.../D2/S5A270.asp
--
- K Dales


"RW" wrote:

I need data from Access. The Access query is based on a table that must be
created first using a Make Table query. How do I run this query from Excel
VBA?

I tried:
200 Set db = OpenDatabase(Name:=strDbName1, _
Options:=False, ReadOnly:=True)
Set qry = db.QueryDefs(strQryName1)
Set rs = qry.OpenRecordset(dbOpenSnapshot)
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

but it fails at:
Set rs = qry.OpenRecordset(dbOpenSnapshot)

I can get the 2nd query to run when the table is created within Access.
However, I need to do all of this on the Excel side.

Thanks

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
Make table query will work in datasheet view but will not make tab WildlyHarry Excel Discussion (Misc queries) 0 August 28th 07 03:06 PM
Make Table Query limitation quartz[_2_] Excel Programming 2 September 30th 05 01:26 PM
Make table query works intermittently quartz[_2_] Excel Programming 2 September 14th 05 09:16 PM
Make Table Query into Text File XP Excel Programming 0 September 14th 05 03:38 PM
Use Excel to make an update query to another database table? Reigning in Seattle Excel Discussion (Misc queries) 2 April 14th 05 06:25 PM


All times are GMT +1. The time now is 12:01 PM.

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

About Us

"It's about Microsoft Excel"