Loop a query

G

Guest

I have written the following code which exports a querys result to a text file

Sub DataExport_loop(
Dim strfile, impdir As Strin
expdir = CurrentProject.Path & "\Export\
strfile = (Dir(expdir & "*.txt")

DoCmd.SetWarnings Fals
DoCmd.TransferText acExportDelim, "ImportSpec", "qry_ASXData_Export", expdir & strfile, Fals
End Su

Field 2 contains various entries for which I would like to use as a condition to generate a report
Say if it contained colours as values (i.e. red, yellow, blue). I would like the query to loop through this to generate 3 reports, red.txt, yellow.txt and blue.txt

Surely this can be done from the 1 query

How should I go about thi

Max
 
G

Guest

I don't see why you think this can be done from one query
when you are creating multiple sets of data.

The simplest way is to create a query for each data set.

If you truly insist on just using the one query, then you
are going to have to use a recordset object to process
each row, and probably create temporary tables holding the
separated information and then finally call TransferText
for each temporary table you created.
 

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