Sometime between 7:30 PM edt 9/19/13 and 4PM edt 9/20/13, fso.write stopped writing normal text and switched to something else; possibly Unicode. After some hours, I modified the code to concatenate the string and then use fso.writeline (you don't want to know why I was using fso.write to begin with). That made some progress in that notepad seems to be able to open the file and display the expected data but there is still something wrong with the text file since it will not import correctly in Access.
This is a 2000-4000 character record with a fixed length header and up to 40 details attached. I was using the write so it was easy for me to view in code what I had collected so far for each record. Please do NOT suggest a different format. Some bozo created this one as his desired import format and I can't change it. I simply have to produce it - which I was until it broke. Yes there were code changes but none in this form.
Although the txt file looks correct in Notepad, there is still something wrong with it. I created an import procedure in a throw-away database to validate this stupid record format. I create an import spec and was importing the file using the import spec and then using a report I created to format the data into something more readable. Here's the bizarre thing - the import wizard shows the first 30 or so records and they look fine. I apply the import spec and the data all lines up swell. I complete the import and then open the imported table in datasheet view. All the columns are there but there are only random characters spread around the fields. I tried using the GUI to import the file and I also tried using TransferText. TransferText has a codepage option but that didn't seem to solve the problem but I may not have been using the correct codepage (1252). I replaced the fso. write with fso.writline and that produced a better file but still not good. I also replaced all the fso with internal Access File I/O and that fails also. Good stuff in but garbage out.
I thought that perhaps my default code page got changed but the code exhibits the same strange behavior on two other computers. Google search has been fruitless. I came up with two similar problems but neither solution completely worked. The one that partially worked was adding the fourth argument - fso.OpenTextFile(filePath,
ForWriting, True, TristateTrue) TristateTrue is supposed to be the default and perhaps that is what changed overnight for me. Specifying TristateTrue made the file "look" OK with notepad but didn't fix Access so there is still something wrong with the way the file is being written and I'm going to guess it revolves around codepages but I don't know how to fix it.