LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Get Query String from Access

Hi Ken

Firstly, I'm no great shakes when it comes to ADO. Hence, I don't know
if this is possible thru ADO. However, I do know it's straight-forward
using DAO to connect to the Access Db. An example of how to return the
SQL of a give query is below:

Sub return_sql()
'set a ref to DAO 3.X - or use late binding
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = OpenDatabase("C:\MyDatabase.mdb")
Set qdf = db.QueryDefs("MyQuery")
Debug.Print qdf.Sql
End Sub

This was a very simple example. I presume if you used this to return
your SQL, you could then utilise this for onward use in the server db.

Do you think this could be of use?

Best regards

Richard


Ken Valenti wrote:
I am using ADO to connect to a SQL database & run queries in Excel 2003.

The SQL code is written in Access, which I then copy to Excel.

I would like to be able to change the queries in Access and have Excel run
the new query without having to manually copy / paste the SQL code to Excel.

Is there a way to get the SQL code for an Access query using code, so I
don't have to copy / paste after a modification to the query has been made?

I would simply use Excel to run the Access query directly, but Access uses
ODBC (which I don't want to setup on everybody's machine).

Thanks


 
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
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
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 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 08:09 AM.

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"