Solved

Replace character

Posted on 2012-12-28
5
206 Views
Last Modified: 2013-01-21
I am trying to clean up some imported data that has numerous special characters eg "-","/","\"," ").i would like to replace the  special characters with ","(chr(44)).I need the most efficient way of doing this.Thanks
0
Comment
Question by:Svgmassive
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38726982
Where is your data coming from?  

What application do you want to do the "cleanup" from (Access or Excel)?

Is this for a single field in the data, or multiple fields?

Could some of these characters ("\") be delimiters for file names or in hyperlinks that should not be removed?
0
 

Author Comment

by:Svgmassive
ID: 38727079
the application is ms access,they are not delimiters and the characters can be removed.Thanks
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38727141
one or more fields?

You can create a simple Update query, something like:

UPDATE yourTable
SET yourField = Replace([yourField], "/", chr$(44))

If you need to do this for multiple fields, and multiple characters, you could create an array of the characters and a second array of field names, then create two loops (one for fields, the other for characters) and run this query inside the inner loop.

This will not work if your table is a Linked Excel worksheet, it will only work if the data has been imported into Access.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 38727553
MyData = Replace(MyData, "/",chr(44))

Do the above for each special character.
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 38727792
If this operation should be done only once, you can open table and use standard find & replace (Find button on ribbon or Ctrl+F). If it should be done many time, use update query with this function:
Function rpl(A As String) As String
Dim Arr As Variant, i As Integer
rpl = A
Arr = Array("-", "/", "\", " ")
For i = 0 To UBound(Arr)
    rpl = Replace(rpl, Arr(i), Chr(44))
Next i
End Function

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now