Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Troubles doing Data Retrieval from SQL

Cheers for the response!

Sorry I should have been more descriptive, it's the first part I'
having the trouble with, the bit where it uses cell input and joins i
all together in a query. I've tried and tried but it doesen't seem t
work properly!?!

Thanks!
Sa

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Troubles doing Data Retrieval from SQL

Is there an easier way of doing dynamically built SQL queries? I can'
think of another way, would anyone be able to suggest anything?

Cheers,
Sa

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Troubles doing Data Retrieval from SQL

Anyone have any ideas on this?

Cheers,
Sa

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Troubles doing Data Retrieval from SQL

You really need to be more specific

I mean like, I've done this in the past...

Build a SQL select Query from Items on Sheet1
Output results of Query to Sheet2

Dim s as String, f as Field, r as long, c as long
s = "SELECT " & Sheet1.Cells(1,1).Value & " FROM " & Sheet1.Cells(2,1).Value & " WHERE " & Sheet1.Cells(3,1).Value
Set rs = cn.Execute(s)
while Not rs.EOF
for each f in rs
Sheets2.Cell(r,c).Value = f.Value
c = c + 1
next
rs.MoveNext
r = r + 1
wend

NOTE: this example has no error handling & is not realy good practice (since Sheet1 might not exist!) but it should get
you started!

If this is not what you need, give a bit more detail - someone will show you the way!

Stevie_Mac...

See ya.

"Sauron " wrote in message ...
Anyone have any ideas on this?

Cheers,
Sau


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Troubles doing Data Retrieval from SQL

Man - thats no good! out clubbing last night! - Try this instead :)
(note to self: Check before posting)


Sub test()
Dim db As Database, rs As Recordset
Set db = Workspaces(0).OpenDatabase("C:\A_DataBase.mdb")
Dim s As String, f As Field, r As Long, c As Long
s = "SELECT " & Sheet1.Cells(1, 1).Value & " FROM " & Sheet1.Cells(2, 1).Value & " WHERE " & Sheet1.Cells(3,
1).Value
Set rs = db.OpenRecordset(s)
r = 1 ' <-- important!
While Not rs.EOF
c = 1 ' <-- important!
For Each f In rs.Fields
Sheet2.Cells(r, c).Value = f.Value
c = c + 1
Next
rs.MoveNext
r = r + 1
Wend
End Sub



"Stevie_mac" wrote in message ...
You really need to be more specific

I mean like, I've done this in the past...

Build a SQL select Query from Items on Sheet1
Output results of Query to Sheet2

Dim s as String, f as Field, r as long, c as long
s = "SELECT " & Sheet1.Cells(1,1).Value & " FROM " & Sheet1.Cells(2,1).Value & " WHERE " & Sheet1.Cells(3,1).Value
Set rs = cn.Execute(s)
while Not rs.EOF
for each f in rs
Sheets2.Cell(r,c).Value = f.Value
c = c + 1
next
rs.MoveNext
r = r + 1
wend

NOTE: this example has no error handling & is not realy good practice (since Sheet1 might not exist!) but it should

get
you started!

If this is not what you need, give a bit more detail - someone will show you the way!

Stevie_Mac...

See ya.

"Sauron " wrote in message ...
Anyone have any ideas on this?

Cheers,
Sau


---
Message posted from http://www.ExcelForum.com/







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Troubles doing Data Retrieval from SQL

Cheers man, really grateful!

The only problem is that other cells can be chosen instead that's why
broke it down into a series of IF statements because it wouldn't wor
if I used a static query, it needs to build based on which cells ar
typed into. Hope that's enough info!

Cheers Very Much!
Sa

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Troubles doing Data Retrieval from SQL

The usual approach is to use static SQL in a stored procedure on the
server side and get the client to pass parameter values.

--

Sauron wrote in message ...
Cheers man, really grateful!

The only problem is that other cells can be chosen instead that's why I
broke it down into a series of IF statements because it wouldn't work
if I used a static query, it needs to build based on which cells are
typed into. Hope that's enough info!

Cheers Very Much!
Sau


---
Message posted from http://www.ExcelForum.com/

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
Data storage/retrieval Adam Excel Discussion (Misc queries) 3 December 12th 07 01:29 PM
Data Retrieval pkpocket Excel Discussion (Misc queries) 2 October 2nd 07 12:50 AM
Excel Form and Data Retrieval Johnny New Englander Excel Worksheet Functions 0 April 4th 06 09:21 PM
Mass book data retrieval Nigel Excel Discussion (Misc queries) 3 March 22nd 06 09:30 AM
MAC Retrieval sparx Excel Discussion (Misc queries) 0 March 19th 06 08:51 PM


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