Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2003 Importing Accented and Foreign Characters Wrong

Posted on 2014-03-13
2
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

Accepted Solution

by:
Gustav Brock earned 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

604 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