Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Reading Textfile into a variable Seth[_3_] Excel Programming 1 April 11th 04 08:46 PM
Changing link to textfile in Pivottable Frank M. Excel Programming 1 November 18th 03 12:35 PM
Textfile-problem Tom Excel Programming 0 August 6th 03 05:01 PM
Opening and saving textfile into XLS MicMast Excel Programming 1 August 4th 03 01:33 PM
Excel VBA to access URL as Textfile Günter Kehrer Excel Programming 1 August 3rd 03 07:54 PM


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