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/