ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sql querries (https://www.excelbanter.com/excel-programming/303823-sql-querries.html)

Delali

sql querries
 
Hi,
this is an excel/access question. i was wondering how to
make excel run a querry in access and put the result of
the querry into a spreadsheet.

thanx a lot

nath

sql querries
 

-----Original Message-----
Hi,
this is an excel/access question. i was wondering how to
make excel run a querry in access and put the result of
the querry into a spreadsheet.

thanx a lot
.


Turn DAO reference on:

Sub Ret_Acc_Qry


Dim dbs as database
dim sql as string
dim rst as recordset

fname = "filename of database"

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbs = wrkJet.OpenDatabase(fname, True)

sql = "sql statement"

set rst = dbs.openrecordset(sql)
h=0

for each fld in rst.fields
activesheet.[a1].offset(0,h).value = fld.name
next fld

activesheet.range("a2").copyfromrecordset rst

dbs.close
end sub


Tom Ogilvy

sql querries
 
Mr. Erlandsen's site has examples of using ADO or DAO
http://www.erlandsendata.no/english/...php?t=envbadac

you can use Data=Get External Data possibly.



--
Regards,
Tom Ogilvy



"delali" wrote in message
...
Hi,
this is an excel/access question. i was wondering how to
make excel run a querry in access and put the result of
the querry into a spreadsheet.

thanx a lot




nath

sql querries
 

-----Original Message-----
Hi,
this is an excel/access question. i was wondering how to
make excel run a querry in access and put the result of
the querry into a spreadsheet.

thanx a lot
.
Sorry before next fld in my response you need h=h+1


nath


All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com