Solved

Access 2003 Importing Accented and Foreign Characters Wrong

Posted on 2014-03-13
2
363 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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now