Solved

Access 2003 Importing Accented and Foreign Characters Wrong

Posted on 2014-03-13
2
364 Views
Last Modified: 2014-05-15
Hi,

I have an import procedure and have for the last 2 years been trying to amend an issue with foreign characters, these get tuned into rubbish text strings on import using the below code

Dim strImpFile As String
    Dim strDecrypt As String
    Dim strComplete As String
    Dim strPrefix As String
    Dim fs, a
    Dim strLine As String
    Dim strSQL As String
    
    'MsgBox strFile
    
    strPrefix = gGetSitePrefix(strFile)
    strDecrypt = Me.OrderPickup
    strComplete = gGetOrderBackup(strPrefix)
    strImpFile = strDecrypt & strFile

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.OpenAsTextFile(strImpFile, 1, False)
    Do While a.AtEndOfStream <> True
        strLine = a.ReadLine
        strLine = Replace(strLine, "'", "")
        strSQL = "INSERT INTO tblImport (NetOrderNo,[Date],[Time],OrderStatus,Email,FirstName,Surname,CompName,Addr,Addr2,Town,County,Postcode,Country,DelName,DelSurname,DelCompName,DelAddr,"
        strSQL = strSQL & "DelAddr2,DelTown,DelCounty,DelPostcode,DelCountry,CustTele,CustDayTele,CustFax,PayMethod,CardType,CardName,CardNumber,ValidToM,ValidToY,ValidFromM,ValidFromY,"
        strSQL = strSQL & "Issue,CVV,Referrer,OrderNote,FindUs,Details,OtherComms,DeliveryDetails,WebsiteDetails,HoldingDate,ProductRef,ProducDesc,Price,Qty,Postage,Newsletter,[BoldNote],[BoldNote1],[BoldNote2],[GiftWrap],[ProductGroupID],[TypeID],[EstShipDate],[ShippingService]) SELECT "
        
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'web ord id
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'date
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'time
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & Left(strLine, InStr(strLine, "|") - 1) & "," 'orderstatus
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbLowerCase) & "'," 'email
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'first
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'last
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'comp
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'add1
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'add2
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'town
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'county
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'postcode
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'country
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'del first
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'last
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'comp
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'add1
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'add2
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'town
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'county
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'postcode
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'country
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'tel
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'fax
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'mob
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & Left(strLine, InStr(strLine, "|") - 1) & "," 'pay meth
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'card type
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & StrConv(Left(strLine, InStr(strLine, "|") - 1), vbProperCase) & "'," 'card name
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & gOnlyNumeric(Left(strLine, InStr(strLine, "|") - 1)) & "'," 'card no
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'exp m
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'exp y
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'val m
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'val y
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'iss
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'cvv
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'ref
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'order note
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'find us
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'details
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'other comms
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'DeliveryDetails
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'WebsiteDetails
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'HoldingDate
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'prod id
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'desc
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & Left(strLine, InStr(strLine, "|") - 1) & "," 'price
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & Left(strLine, InStr(strLine, "|") - 1) & "," 'qty
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & Left(strLine, InStr(strLine, "|") - 1) & "," 'del charge
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Newsletter
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Bold Note
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Bold Note 1
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Bold Note 2
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Gift Wrap
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "'" & Left(strLine, InStr(strLine, "|") - 1) & "'," 'Product Group ID
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        'MsgBox (strLine)
        
        
        strSQL = strSQL & "" & Left(strLine, InStr(strLine, "|") - 1) & "," 'Product Group ID]
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        strSQL = strSQL & "#" & Left(strLine, InStr(strLine, "|") - 1) & "#," 'Product Group ID]
        strLine = Right(strLine, Len(strLine) - InStr(strLine, "|"))
        
        'MsgBox (strLine)
        strSQL = strSQL & "'" & strLine & "';" 'Type ID
        
       
        
        
        'MsgBox strSQL
        
          DoCmd.RunSQL strSQL
        
        strLine = ""
    
    Loop
    a.Close
    Set a = Nothing

Open in new window


Any ideas on how I can stop it?

Cheers
Karl
0
Comment
Question by:Kbba04527
2 Comments
 
LVL 15

Expert Comment

by:gplana
ID: 39926092
I don't know which character encoding is your file from you are importing this data. However, I think it will be useful for you to look at this link:

http://office.microsoft.com/en-us/access-help/strconv-function-HA001228915.aspx

Which explains about strConv function to convert from different character encodings.

Hope it helps. Regards.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39926093
Use a DAO recordset and .AddNew and not "SQL INSERT ..":

http://www.experts-exchange.com/Database/MS_Access/Q_28381863.html#a39909771

It will also run a magnitude faster.

/gustav
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Server 2012 management. 5 23
VB Script: restart service function 30 36
Web Browser embedded in MS Access form hangs after logging into website 8 49
Dlookup MSACCESS 5 24
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question