How can I make A2K write to a textfile..

A

A E

I would like to write to a textfile with one or more head rows and then the
records that I want to export. Does anyone have an example code or a
suggestion how to do it. The solution I have in mind also requires a foot
row in the created file. Please reply. /A E
 
K

Kevin Ellis

The most flexable way would be standard VB code to create a textfile. Look
in the VBA documentation for the "open" statement. Off-hand it's something
like:
dim i%
i = freefile
open "<filename>" for output as i
print i, "your text" & "more text" & etc.
close i

loop the print for each record or nest a loop for each field.

you could also look under the File->Export menu and setup an export
specification for a query. This allows header rows but not footer.

cheers,
k
 
T

ThomasW

I'll throw in my two cents worth while i see if anyone will reply to my post
in this forum.

Here's a little code I'd used to write to a log file a few years back.

' Write info to a text log file.

Set fs = CreateObject("Scripting.FileSystemObject")
' Open file for appending, and create if it doesn't exist.
Set f = fs.OpenTextFile("c:\BigDB\Logfile.txt", 8, -1)
' Write this record's fields, separated by tabs
writestr = Chr(9) & Str(RecSet![PatientID])
writestr = writestr & Chr(9) & Str(RecSet![ContactNumber])
writestr = writestr & Chr(13) & Chr(10)
f.Write writestr
f.Close

This is just how I did it, and it worked. That's not to say there aren't
better or easier ways to do it. This doesn't address your header and footer
issue, which I'd think would involve using an index which is incremented as
you write lines, so you'd know where to place the footer.

Good luck.

Thomas Wentzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top