View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
nathan nathan is offline
external usenet poster
 
Posts: 14
Default SQL-Query from a textfile?

It is possible my friend, i have assumed you are running the SQL from an access db

Here goe

Sub TXT_Sq

dim sql, strSQL, fname as strin
dim dbs as databas
dim rst as recordse

fname = "sqltextfile

open fname for input as #

input #1,strSQ

close #

Set wrkjet = CreateWorkspace("", "admin", "", dbUseJet) ' Create workspace to handle the DB
Set dbs = wrkjet.OpenDatabase("AccessDatabaseName.mdb", True) ' Open the DBS, put in your db filenam

set rst = dbs.openrecordset (sql) ' open recordset with sq

range("a1").copyfromrecordset rs

dbs.clos

end su

Any probs leave a note on here and i'll do my best to hel

nath