Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create multiple text files from a table of data? 2

Status
Not open for further replies.

steveroot

IS-IT--Management
Dec 29, 2000
20
GB
Hello all, can anyone help me with this please?

I have a table of data, something like,

Widgets £3.00
Gizmos £8.00

I would like to create a text file for each line on the table, so the first line would become a text file called 'widges.txt', and contain the string "widgets £3.00", the second line a file called 'Gizmos.txt' and contains "Gizmos £8.00".

I have used a module to get each line as a variable in a loop, but I can't work out any way of creating the text file from the module using the variables? Does anyone know how to do this bit please?

--
Steve Root
 
Sure use the Open command

Open Filename for Output as #1
Print #1, Yourdata
Close#1 DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
you don't turn #1, you use the name you stored in the String variable Filename

dim Filename as string

Filename="C:\output.txt"

open Filename for Output as #1
Print #1, "hello"
Close #1

you will have to set up some looping code to run through all the data in your table, taking the name of your product, and making a filename from it, opening the file, writing your data, closing the file, and looping back again

dim rs as adodb.recordset
set rs=new adodb.recordset

rs.open "SELECT productname, productprice FROM products", CurrentProject.Connection

while note rs.eof
Filename = "C:\temp\" & rs("productname") & ".txt"
open Filename for output as #1
print #1, rs("productprice")
close #1
rs.movenext
wend
rs.close
set rs=nothing

there you go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top