Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL-Query from a textfile?
Hi everyone, I really have a difficult question and dunno if it's
possible.Let me explain what I want. I want to create a userform with VBA in Excel where a user can brows to some textfiles(or other files).In the text file there will be SQL-query code. When user selected the file it must run the Query an store the result of the query in a few cells. Please reply I've you can help me creating a beginning (or even mor :) ) Hope you can help me, GreetZ from Stif -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL-Query from a textfile?
No I won't use Access, But Excel and get data from a SQL-DB
-- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL-Query from a textfile?
Where do I have to put the code in? Behind a CommandButton or in m
Userform.Initiate or what ? Where do I have to put te txt files. Sorry I don't have very much experience with VBA -- Message posted from http://www.ExcelForum.com |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL-Query from a textfile?
If you want it to happen on a command button click, then put it behind the command button. If you want it to happen when you opent the form, then put it on the initialize. Are you querying SQL server?
|
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
SQL-Query from a textfile?
~× wrote:
*If you want it to happen on a command button click, then put i behind the command button. If you want it to happen when you open the form, then put it on the initialize. Are you querying SQ server? * No I'm Querying and Oracle D -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reading Textfile into a variable | Excel Programming | |||
Changing link to textfile in Pivottable | Excel Programming | |||
Textfile-problem | Excel Programming | |||
Opening and saving textfile into XLS | Excel Programming | |||
Excel VBA to access URL as Textfile | Excel Programming |