473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

From multiple queries, how to script a .txt file

I have about 20 MS Access 97 queries. Instead of openning each one
manually and seeing what's wrong (error reports), I would like to have
each query sent to a .txt file. I've played with Transfer Text a bit,
but here's my ultimate goal if you have any suggestions.

1. delete contents, not file, of target .txt file from previous date
(C:/ErrorReport.txt)

2. Add the following text before running first query at
C:/ErrorReport.txt
Query 1 results:
3. append results of Query1 to C:/ErrorReport.txt
4. add new line
5. Add the following text before running second query at ....
6. append results of Query2 to C:/ErrorReport
7. add new line

all the way to last query.

What direction would you recommend?

TIA

Nov 13 '05 #1
2 2041
for 1., I would just use a Kill statement to get rid of the file.
What's the difference?

I would probably loop through the querydefs, open each into a
recordset, and then output them all to a single file. Either that or
output them all using TransferText and then use DOS commands to copy
the intermediate files to the final file. Otherwise, you'd do
something like...

'delete text file
if Dir(strFilePath)<>0 then
Kill strFilePath
end if

open your text file
'see OpenFile...

loop through the querydefs collection... something like
dim qdf as querydef
dim rs as dao.recordset
for each qdf in dbEngine(0)(0).Querydefs
set rs=qdf.OpenRecordset
write #1 vbcrlf 'put in the blank line...
do until rs.EOF
'write your fields values to the text file
for intCounter = 0 to qdf.fields.count-1
if intCounter = 0 then
strTemp=qdf.fields(intcounter)
else
strTemp=strTemp & cDELIM & qdf.fields(intCounter)
next intCounter
put #1, strTemp
rs.close
.....

Does that get you started?
Look up Open, Write/Put, QueryDefs, and that should get you started...
you have to loop through the querydefs, open them one at a time into a
recordset, loop through each field, write that to a string, and then
write that string to your text file. Lather, rinse, repeat. Go to
next query...

Nov 13 '05 #2
First off, #1 is a bit silly. "delete contents, not file"? What would
be the purpose of that. Why not just delete the file and create a new
file with the same name?

For the rest, try Dimitri Furman's TextExport class:
http://www.mvps.org/access/modules/mdl0058.htm or
http://www.users.cloud9.net/~dfurman.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rock72 | last post by:
Hello there, Can anyone tell me how to create a php script that when the user click the Submit button, a message will be sent to friends email add stored in mysql table? I created this ff...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
3
by: michaelnewport | last post by:
Greetings, I have what seems a simple problem.... I want to save the output from the following queries in 1 file in 'SQL Query Analyser', but I can only save each 'grid' separately. I have...
2
by: Jenny Zhang | last post by:
Hi, I am running OSDL-DBT3 test against PostgreSQL. I found performance difference between the runs even though the data and queries are the same. I tried to study this problem by getting...
1
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I...
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am thinking about doing this since I got several cases that some of our internal users open more than one browser at the same time from our server. When one of the transactions was not...
4
by: dreaken667 | last post by:
I have a MySQL database containing 16 tables of data. Each table has a different number of columns and there are few common field names accross tables. I do have one master table with which I connect...
4
by: Akhenaten | last post by:
I am currently using enterprise manager to run multiple queries on a single table in a DB. I refresh these queries every few minutes. Due to the huge number of them I was looking for a better way...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.