Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Retrieving data with SQL from ODBC source

Need help with retrieving data using SQL via an ODBC source. Need to use a cell value as a retrieval key. Can someone point me to a good reference for this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Retrieving data with SQL from ODBC source

Hi Clint,

Here is some code that you can modify. I have used a variable called User as
the entry from an Input box, but you can change it to reference a cell value
too.

User = InputBox("Who are you?", "Enter your name", "Bede")
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=MS Access Database;DBQ=P:\BugDataBase\DI
CM.mdb;DefaultDir=P:\BugDataBase;DriverId=281;FIL= MS
Access;MaxBufferSize=2048;Pag" _
), Array("eTimeout=5;")), Destination:=Range("A1"))
.CommandText = Array( _
"SELECT `Bugs`.bug_id, `Bugs`.priority, `Bugs`.description,
`Bugs`.date, `Bugs`.bug_assignee, `Bugs`.reported_by, `Bugs`.resolution" _
, _
", `Bugs`.fixed" & Chr(13) & "" & Chr(10) & "FROM `P:\BugDataBase\DI
CM`.`Bugs` `Bugs`" & Chr(13) & "" & Chr(10) & "WHERE (`Bugs`.reported_by
Like '%" & User & "%')" _
)
.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

HTH, Greg

"Clint" wrote in message
...
Need help with retrieving data using SQL via an ODBC source. Need to use

a cell value as a retrieval key. Can someone point me to a good reference
for this?


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
Changing data source on ODBC query Aussie CPA Excel Discussion (Misc queries) 2 June 14th 07 05:44 PM
change odbc data source jenn Excel Worksheet Functions 0 January 20th 06 12:12 AM
Retrieving data with SQL and ODBC selected by key values in cells Clint[_2_] Excel Programming 1 April 12th 04 02:11 PM
Retrieving data from Access via SQL/ODBC Oliver[_2_] Excel Programming 0 January 7th 04 07:30 PM
Retrieving Source Data From Pivot Table John Units Excel Programming 1 September 9th 03 08:07 PM


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