Replacing all "á" with blank

User avatar
JudyJones
StarLounger
Posts: 72
Joined: 08 Mar 2010, 13:05
Location: Manassas, VA

Replacing all "á" with blank

Post by JudyJones »

I have a linked text file that has a number of fields containing the following character that is mixed in with good data: á

I can manually accomplish what I want to do by using find and replace for all fields and asking for the á to be replaced with a space. Is there a way that can be automated other than using a separate query for each field?

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Replacing all "á" with blank

Post by JohnH »

You could do it with a single update query, that updates each field using the Replace function.
Regards

John

User avatar
JudyJones
StarLounger
Posts: 72
Joined: 08 Mar 2010, 13:05
Location: Manassas, VA

Re: Replacing all "á" with blank

Post by JudyJones »

I tried using the replace function and could not figure out how to get the query to search through multiple fields to accomplish the replacement. I have attached a sample database containing 5 records. My actual table has over 12,000 records. Could you show me how to use the replace function on all the fields?
You do not have the required permissions to view the files attached to this post.

User avatar
mbarron
2StarLounger
Posts: 112
Joined: 25 Jan 2010, 20:19

Re: Replacing all "á" with blank

Post by mbarron »

You can do a Find and Replace within the table itself. Open the table press Ctrl+H, enter the á in the Find What and leave the Replace With empty. Choose the entire table for the Look In and set the Match to Whole Field.

User avatar
JudyJones
StarLounger
Posts: 72
Joined: 08 Mar 2010, 13:05
Location: Manassas, VA

Re: Replacing all "á" with blank

Post by JudyJones »

I know that I can do that process manually. What I am looking for is a way to accomplish it automatically through a query or code so that it will be just one step in an automatic process to prepare the file for exporting for another program to use.

User avatar
mbarron
2StarLounger
Posts: 112
Joined: 25 Jan 2010, 20:19

Re: Replacing all "á" with blank

Post by mbarron »

Try this:

Code: Select all

DoCmd.SetWarnings False
    Dim Rst 'As Recordset
    Dim f 'As Field

    Set Rst = CurrentDb.OpenRecordset("TempTable")

    For Each f In Rst.Fields
    If f.Type <> 4 Then
            DoCmd.RunSQL "update TempTable  set [" & f.Name & "] = """" where [" & f.Name & "] = ""á"""
    End If
    Next
    
    Rst.Close
DoCmd.SetWarnings True

User avatar
JudyJones
StarLounger
Posts: 72
Joined: 08 Mar 2010, 13:05
Location: Manassas, VA

Re: Replacing all "á" with blank

Post by JudyJones »

That worked like a charm. Thank you very very much.