ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How To Pull Access Query into Excel (2003): Reposting (https://www.excelbanter.com/excel-programming/318481-how-pull-access-query-into-excel-2003-reposting.html)

Bettergains

How To Pull Access Query into Excel (2003): Reposting
 
Hello: i previously posted code that successfully pulls an Access 2003 table
into an Excel 2003 spreadsheet. How is this done pulling a query, using a
query name? (Not using a SQL string that defines the query.)

Thanks~

onedaywhen[_2_]

How To Pull Access Query into Excel (2003): Reposting
 
Bettergains wrote:

Hello: i previously posted code that successfully pulls an Access

2003 table
into an Excel 2003 spreadsheet. How is this done pulling a query,

using a
query name? (Not using a SQL string that defines the query.)


If it is a VIEW type query

SELECT MyCol1, MyCol2 FROM MyQuery;

If it a PROCEDURE type query:

EXECUTE MyQuery arg1, arg2
or
{CALL MyQuery arg1, arg2}

Jamie.

--


TK

How To Pull Access Query into Excel (2003): Reposting
 
Hi Bettergains

A couple more suggestions if your using ADO. you didn't really give much
information.

I use the following:

' When using a connection object

cnn.Open
Set Rs = cnn.Execute("Your Query Name", , adCmdStoredProc)

' When using a Command object

cnn.Open
CMD.ActiveConnection = cnn
CMD.CommandText = "[Your Query Name]"
CMD.CommandType = adCmdUnknown
Set Rs = CMD.Execute

Good Luck
TK


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com