|
 |
access thread: Exporting to csv
Message #1 by "Tim Maher" <tim.maher@s...> on Fri, 14 Mar 2003 14:09:17 +0000
|
|
Hello,
Ive got the following code that exports a large table to a csv file.
'open the file
fno = FreeFile
Open "c:\test.csv" For Output As #fno
'create the recordset
s = "SELECT * FROM EXPORT_TO_CSV;"
Set ds = db.OpenRecordset(s, dbOpenDynaset)
'now create the csv file contents
Do While Not ds.EOF
For i = 0 To ds.Fields.Count - 1
If i = ds.Fields.Count - 1 Then
Write #fno, ds.Fields(i)
Else
Write #fno, ds.Fields(i),
End If
Next i
ds.MoveNext
Loop
Close #fno
The export works fine, however, there are blank fields in the recordset
which when exported show up as #NULL# when the csv file is viewed. how
can i export this file without #null# appearing i:
file to show :
,RVCC7,,M,45663,2
instead of :
,RVCC7,#NULL#,M,45663,2
Many thanks
Tim
This e-mail transmission is strictly confidential and intended solely
for the person or organisation to who it is addressed. It may contain
privileged and confidential information and if you are not the
intended recipient, you must not copy, distribute or take any action
in reliance on it.
If you have received this email in error, please notify us as soon as
possible and delete it.
This e-mail has been scanned using Anti-Virus software, however,
Swansea NHS Trust accept no responsibility for infection caused by
any virus received on the recipients system.
Message #2 by George Sideris <george.sideris@g...> on Fri, 14 Mar 2003 09:43:58 -0500
|
|
Use another if statement at the proper place. You can use the IsNull(...)
function to find out if a field is null!
-----Original Message-----
From: Tim Maher [mailto:tim.maher@s...]
Sent: Friday, March 14, 2003 9:09 AM
To: Access
Subject: [access] Exporting to csv
Hello,
Ive got the following code that exports a large table to a csv file.
'open the file
fno = FreeFile
Open "c:\test.csv" For Output As #fno
'create the recordset
s = "SELECT * FROM EXPORT_TO_CSV;"
Set ds = db.OpenRecordset(s, dbOpenDynaset)
'now create the csv file contents
Do While Not ds.EOF
For i = 0 To ds.Fields.Count - 1
If i = ds.Fields.Count - 1 Then
Write #fno, ds.Fields(i)
Else
Write #fno, ds.Fields(i),
End If
Next i
ds.MoveNext
Loop
Close #fno
The export works fine, however, there are blank fields in the recordset
which when exported show up as #NULL# when the csv file is viewed. how
can i export this file without #null# appearing i:
file to show :
,RVCC7,,M,45663,2
instead of :
,RVCC7,#NULL#,M,45663,2
Many thanks
Tim
This e-mail transmission is strictly confidential and intended solely
for the person or organisation to who it is addressed. It may contain
privileged and confidential information and if you are not the
intended recipient, you must not copy, distribute or take any action
in reliance on it.
If you have received this email in error, please notify us as soon as
possible and delete it.
This e-mail has been scanned using Anti-Virus software, however,
Swansea NHS Trust accept no responsibility for infection caused by
any virus received on the recipients system.
|
|
 |