LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default MS Query - From in SQL

In addition to updating the Connection property to update the DB command
string, in order to change the FROM clause in the SQL you will need to modify
the CommandText property, which should contain the SQL query. You could use
the Replace function to modify it, e.g.
Replace(Sheets("MySheet").QueryTables(1).CommandTe xt, "FROM AAA", "FROM BBB")

"Robert Bruce" wrote:

mtate wrote:
Question...
We have quite a few queries developed in Excel/MS Query that query an
AS400. We need to share these with users at other locations that use
an AS400 with a different name. Is there any way around changing the
SQL FROM statement for the AS400 machine name to another AS400
machine name without editing the query in MS Query and doing it in
View, SQL? Looking for the quick, easy way to do this, because there
are too many to change this way.


If you used MSQuery to return the results then you will have a QueryTable
object on your worksheet. As long as you chose to save the query definition
with the sheet, the QueryTable object will have a Connection property that
corresponds to the connectionstring used by the query. Your mission, I
suppose, is to ensure that this property is updated with the appropriate
value depending on who opens the workbook. You could put a lookup table of
usernames and connectionstrings on a hidden sheet.

Rob



 
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
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Importing Data via Web Query - Can values be passed to query? [email protected] Excel Discussion (Misc queries) 5 May 9th 06 06:21 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
Edit Query from Excel will not open query in MSQuery Michelle Excel Programming 0 February 21st 05 03:59 PM


All times are GMT +1. The time now is 09:34 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"