Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Reading from a text file in vba

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Olsen - 31 Jan 2006 15:11 GMT
Hi,
  I would like to send queries straight to the Oracle database that I am
connecting to.  I do not want Access to process it since they seems to be a
lot faster when I use a pass through query.  However, I want to use variables
in the SQL statements which I dont believe pass through queries will work.  
So I want to use vba code to send the queries through and then output the
results to excel.  I was thinking that maybe the best way to do this would be
to have text files of the queries that I can read into string variables.  
Some of the queries are pretty unwieldy and I dont want them hardcoded.  So
my question is:  How can I read in a full text file into a string variable?

Mark
Klatuu - 31 Jan 2006 15:25 GMT
There is an easier way.  All stored queries in Access are stored as SQL
strings.  The query builder you see only converts it to a GUI so it is easier
to use than writing SQL by hand.  When you save a query from the query
builder, it converts it back to the SQL.  So all you need to do is read the
SQL string from the Querdef into a string variable and do whatever you want
with it.

strSQL = CurrentBb.QueryDefs("MyQueryName").SQL

> Hi,
>    I would like to send queries straight to the Oracle database that I am
[quoted text clipped - 8 lines]
>
> Mark
Mark Olsen - 31 Jan 2006 16:15 GMT
Hi, Thanks.  Im using ADO though.  Will that work with ADO?

Mark

> There is an easier way.  All stored queries in Access are stored as SQL
> strings.  The query builder you see only converts it to a GUI so it is easier
[quoted text clipped - 17 lines]
> >
> > Mark
Klatuu - 31 Jan 2006 16:38 GMT
This has nothing to do with DAO or ADO.  Queries, regardless of type, are
saved this way.  As long as the query you define works with ADO, this
technique will work.  It is much easier than trying to maintain and read a
text file.

> Hi, Thanks.  Im using ADO though.  Will that work with ADO?
>
[quoted text clipped - 21 lines]
> > >
> > > Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.