View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
MTate MTate is offline
external usenet poster
 
Posts: 8
Default ms query - from statement

I am fairly new to this type of thing, so bear with me. I get the attached
error: 424 Object Required after inputting the AS400 ID. My code is as
follows (I'm sure I did something wrong...)

Const OriginalID = "DASSMY"
AS400ID = InputBox("Enter the AS400 name:")
Sheets("Colors").QueryTables("DASPVIEWS.COLOR_CODE ").CommandText =
Replace(MyQueryTable.CommandText, OriginalID, AS400ID)

Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Cells.Select
Selection.Columns.AutoFit
ActiveWorkbook.Save

I'm running this from a button on the spreadsheet. My original AS400
machine id is DASSMY. The table is located at DASPVIEWS.COLOR_CODE. This is
the library and table name.
Any way to enter the machine id into a cell on the Worksheet? Any help
would be appreciated.



"mtate" wrote:

We have numerous queries that we would like to run against AS400's at
different locations. The problem is each AS400 has a different machine id.
When a ms query is created in Excel it records this in the FROM statement in
the SQL. Is there any way to get around this? We know how to change the
SQL, but want to be able to prompt for the AS400 name or at least enter it
into a cell on the worksheet. Is this possible?