Microsoft KB Archive/210542

= ACC2000: Unexpected Characters Appear in Imported dBASE IV Database =

Article ID: 210542

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210542



This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
Unexpected characters, specifically characters Chr(10) and Chr(236), appear approximately every 65th character within a Memo field of an imported dBASE IV or Paradox database.



CAUSE
These characters are used by dBASE IV so that its memo editor word wraps automatically. The dBASE IV memo editor has a fixed line length of 65 characters, and the mechanism is stored in the data so that the memo editor does not have to force the word wrap.



RESOLUTION
Use the following procedure and sample code to remove the Chr(10) and Chr(236) characters from the data. This procedure will not damage the data, and you can export the data back to dBASE IV later if you want to:   In the Access 2000 database or project that contains the imported dBASE IV file, type or paste the following procedure in a new module: Option Compare Database Option Explicit

Sub subMemoFix(strTblName As String, strFldName As String)    'This code requires a reference to the following object library: '   '   Microsoft ActiveX Data Objects 2.x Library '   'where 2.x is equal to 2.1 or higher.    Dim con As ADODB.Connection Dim rst As ADODB.Recordset Dim strOldMemo As String Dim strNewMemo As String Dim intStart As Integer

Set con = CurrentProject.Connection Set rst = New ADODB.Recordset

rst.Open strTblName, con, adOpenDynamic, adLockOptimistic rst.MoveFirst

Do Until rst.EOF If rst(strFldName) <> "" Then strOldMemo = Trim(rst(strFldName)) strNewMemo = ""

For intStart = 1 To Len(strOldMemo) If Mid(strOldMemo, intStart, 2) = (Chr(236) & Chr(10)) Then intStart = intStart + 1 Else strNewMemo = strNewMemo & Mid(strOldMemo, intStart, 1) End If           Next

rst(strFldName) = strNewMemo rst.Update End If       rst.MoveNext Loop

rst.Close con.Close Set rst = Nothing Set con = Nothing

Debug.Print Debug.Print "Done" End Sub   To test this function, type the following line in the Immediate window subMemoFix " ", " " where is the name of the imported dBASE IV table and is the name of the Memo field, and then press ENTER.

For example, for a table that is named CUSTOMERS that has a Memo field that is named NOTES, type: subMemoFix "CUSTOMERS", "NOTES" 



MORE INFORMATION
The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Additional query words: prb

Keywords: kbinterop kbprogramming kbprb KB210542

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.