T
Tim Chmielewski
The following code is meant to take records from a database and write
them to a file in a comma delimited CSV format:
Set fso = CreateObject("Scripting.FileSystemObject")
filename1 = FilePath & filename1
Set f1 = fspenTextFile(filename1, ForWriting, True)
f1.WriteLine "Name,School,Address Line 1,Address Line 2,Address Line
3,Address Line 4,Date Requested"
Do While Not rs.EOF
strAddress = rs("PostalAddress")
arrAdd = Split(strAddress, vbcrlf)
For i = LBound(arrAdd) to Ubound(arrAdd)
ArrGetAdd(i) = arrAdd(i)
Next
'The following line generates an exception
f1.WriteLine rs("Name") & "," & rs("School") & "," & ArrGetAdd(0) &
"," & ArrGetAdd(1) & "," & ArrGetAdd(2) & "," & ArrGetAdd(3) & "," & rs
("DateRequested")
rs.MoveNext
Loop
f1.Close
shortpath = "<BR><A HREF=" & QUOT & filename2 & QUOT & ">View CSV
File</A><BR>"
At first I thought it was something to do with the array, but it would
have said it was an 'array out of bounds' error if that was the case.
I have tested the values in the ArrGetAdd array and they seem to have
been stored fine.
Is there anything else I have missed that could be causing the error?
Thanks.
them to a file in a comma delimited CSV format:
Set fso = CreateObject("Scripting.FileSystemObject")
filename1 = FilePath & filename1
Set f1 = fspenTextFile(filename1, ForWriting, True)
f1.WriteLine "Name,School,Address Line 1,Address Line 2,Address Line
3,Address Line 4,Date Requested"
Do While Not rs.EOF
strAddress = rs("PostalAddress")
arrAdd = Split(strAddress, vbcrlf)
For i = LBound(arrAdd) to Ubound(arrAdd)
ArrGetAdd(i) = arrAdd(i)
Next
'The following line generates an exception
f1.WriteLine rs("Name") & "," & rs("School") & "," & ArrGetAdd(0) &
"," & ArrGetAdd(1) & "," & ArrGetAdd(2) & "," & ArrGetAdd(3) & "," & rs
("DateRequested")
rs.MoveNext
Loop
f1.Close
shortpath = "<BR><A HREF=" & QUOT & filename2 & QUOT & ">View CSV
File</A><BR>"
At first I thought it was something to do with the array, but it would
have said it was an 'array out of bounds' error if that was the case.
I have tested the values in the ArrGetAdd array and they seem to have
been stored fine.
Is there anything else I have missed that could be causing the error?
Thanks.