Read and write to a .txt file from ACCESS VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have been reading and searching trying to find how to do this. I need to
read a table and create a text file with one row for each row in the table.
Then I need to read a CSV .txt file in and place those values in a table,
row for row.
From the reading, looks like I may OPEN for INPUT or OUTPUT, and then do a
read or write? I am having trouble finding specifics or even better yet, an
example.
If anyone can point me in the right direction, I would be thankful.
Thanks,
Steve
 
Here is how I am trying to do it:

Read:

Open "c:\Test.txt" For Output As #1
Loop
Print #1, oAlias.Code
end loop
Close #1

Write:

Open "c:\trans.txt" For Input As #1
loop
Input #1, Field1, field2, field3, field4, field5, field6
end loop
Close #1

QUESTION:
I don't know what to check for in my loop on my read to see End of file and
quit the loop?

Steve
 
Hi Steve,

Accesss can export data to standard textfile formats such as CSV,
tab-delimited and fixed-width. It can also import data from many files
in these formats. From VBA, both operations are done with
DoCmd.TransferText.
 

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

Back
Top