C
Christian Nein
Hi,
I have a Access 2003 database with a table containing unicode (UTF-8)
characters (chinese) in some fields. I tried to export the table into a
textfile with the code below but the textfile just contained question marks.
For some reason, the unicode characters are not written correctly to the
file.
Do I have to use some Windows-DLL to write unicode-text files?
Thanx & best regards
Christian
Function ExportToCsv(sRecordset As String) As Boolean
On Error GoTo Err_ExportToCsv
Dim DB As Database
Dim RS As Recordset
Dim s As String
Dim line As String
Dim f As Field
Dim i As Integer
ExportToCsv = True
Set DB = CurrentDb
Set RS = DB.OpenRecordset(sRecordset, dbOpenSnapshot)
Open "C:\test.csv" For Output Access Write As #1
RS.MoveLast
RS.MoveFirst
For i = 1 To RS.RecordCount
For Each f In RS.Fields
If Not IsNull(f.Value) Then s = f.Value
line = line & s & ","
Next f
Write #1, line
line = ""
RS.MoveNext
Next i
Exit_ExportToCsv:
Close #1
Exit Function
Err_ExportToCsv:
ExportToCsv = False
MsgBox Err.Description
Resume Exit_ExportToCsv
End Function
I have a Access 2003 database with a table containing unicode (UTF-8)
characters (chinese) in some fields. I tried to export the table into a
textfile with the code below but the textfile just contained question marks.
For some reason, the unicode characters are not written correctly to the
file.
Do I have to use some Windows-DLL to write unicode-text files?
Thanx & best regards
Christian
Function ExportToCsv(sRecordset As String) As Boolean
On Error GoTo Err_ExportToCsv
Dim DB As Database
Dim RS As Recordset
Dim s As String
Dim line As String
Dim f As Field
Dim i As Integer
ExportToCsv = True
Set DB = CurrentDb
Set RS = DB.OpenRecordset(sRecordset, dbOpenSnapshot)
Open "C:\test.csv" For Output Access Write As #1
RS.MoveLast
RS.MoveFirst
For i = 1 To RS.RecordCount
For Each f In RS.Fields
If Not IsNull(f.Value) Then s = f.Value
line = line & s & ","
Next f
Write #1, line
line = ""
RS.MoveNext
Next i
Exit_ExportToCsv:
Close #1
Exit Function
Err_ExportToCsv:
ExportToCsv = False
MsgBox Err.Description
Resume Exit_ExportToCsv
End Function