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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping file output

Status
Not open for further replies.

xollox

Technical User
Jun 28, 2002
18
US
Hello all,

Here is my question...
I have a loop in my access module that loops through orders and outputs some XML for each. I am having trouble getting the file output to work correctly. Here is a little code snippet of what I'm doing (with most of the code removed):

For i = 1 To 3
Open TempPath & "xmldef.xml" For Output As #1
Print #1, "whatever"
Close #1
FileCopy TempPath & "xmldef.xml", OtherPath & "xmldef.xml"
Kill TempPath & "xmldef.xml"
next i

With the code as it stands, when it loops and hits the open statement for the second time, it gives a "File already open." If I don't close the file and I try to copy it, it gives me a "File not closed" error. If I try write to the file without opening it again for the second iteration, it gives me a "file not open" error. So what am I supposed to do?

Thanks in advanced for any help you can provide.



-XolloX
 
I found the error with my code...It's one of the nested loops (the one that contains the close statement) is not being run... oops.

-XolloX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top