Solved

Replace character

Posted on 2012-12-28
5
209 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 46

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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