#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel Query

I have a Research.xls file which has a list of discovered Tech Items in the
Discovery sheet. This information is queried into a file called PopGrp.xls
which list the available tech and allows production of those items.

I have set up the query and it works the way it's supposed to...that is as
long as the file is never moved or renamed. The problem arises when the
player has more than 1 empire and/or if they want to save their files into a
different directory. That empire needs to have a separate Research.xls file
and PopGrp.xls file and the path to that file needs to be adjusted in the
query.

How can I create a query with programming code in PopGrp.xls with the
following:

PathName = Worksheets("Start").Cells(1,1)
FileName = "Research " & EmpID & ".xls"
The Query would grab info from:

PathName & FileName
Worksheets("Discovery")
Fields: T#, TechName

The information would be placed in Worksheets("Flow").Range("F2")
Overwriting Cells and copying down adjacent formulas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel Query

This is what Excel records when I record the Query as a macro using the Query
Wizard of Excel 2003:

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=Excel Files;DBQ=D:\Research
4851.xls;DefaultDir=D:;DriverId=790;MaxBufferSize= 2048;PageTimeout=5;" _
, Destination:=Range("N2"))
.CommandText = Array( _
"SELECT `Discover$`.`#`, `Discover$`.`Tech Name`" & Chr(13) & "" &
Chr(10) & "FROM `D:\Research 4851`.`Discover$` `Discover$`" & Chr(13) & "" &
Chr(10) & "ORDER BY `Discover$`.`#`, `Discover$`.`Tech Name`" _
)
.Name = "Query from Excel Files_7"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = True
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
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
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Query from microsoft query- Excel 2007 טבלאות אקסל 2007 Excel Discussion (Misc queries) 0 December 24th 07 10:47 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 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
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 07:38 PM.

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

About Us

"It's about Microsoft Excel"