I have been working on an export file(csv) for a while now that is giving me nothing but headaches. The file is returning all of the correct data that I am wanting, but it is writing it to the file three times. Each record would have 3 times the data each time the file is exported.

I first thought the problem might be my Select statement. My JOIN clause is correct and the Select statement is returning the correct amount of rows. I now know the problem resides in my code somewhere.

This is a very complicated export(not so much the code, but just understanding what happens). I was hoping someone could evaluate a large chunk of the export code for me. It is a rather large piece of code, so rather than cluttering a screen with it, I would like to ask if anyone would mind evaluating via email. If not, let me know a viable means.