Results 1 to 3 of 3
  1. #1
    Dordee is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    2

    Replace Function Based on Beginning of Field

    I have a large database of city names, and I need to replace many abbreviations and punctuation with spaces and/or spell out the name. Using Find and Replace is too time consuming and crashes Access because there are so many records so I was thinking of doing it with an Update Table query using a REPLACE function.

    One problem I am having is that I want the string that it is looking for to only change if it matches the beginning of the field.

    For example, if "ST " starts at the beginning of the field, I want to replace it with "SAINT ".


    However, if "ST " is anywhere else - for example "FIRST N", I don't want it changed.

    It seems really simple, as I can query this, and do it using Find and Replace, but I can't find how to do it with the REPLACE function. I even looked into a little doing it in the SQL view in Access.

    Any ideas?

    Thank you!

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Think you will have many more issues so should try to determine as many of them as possible before deriving a solution but with regards the one you mention try

    newstring=replace(left(oldstring,3),"ST ","SAINT ") & mid(oldstring,4)

  3. #3
    Dordee is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    2
    Thank you so much! I do have many to change, but only one or two in which the string must match the first positions. The rest I can handle with a space before or after. I will give this a try - thanks again!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replace Function
    By razkowski in forum Queries
    Replies: 7
    Last Post: 10-08-2014, 02:28 PM
  2. Help with Replace Function...
    By redbull in forum Programming
    Replies: 5
    Last Post: 06-27-2013, 04:05 PM
  3. Replies: 1
    Last Post: 11-30-2012, 05:57 AM
  4. Replies: 3
    Last Post: 06-07-2012, 07:05 AM
  5. Replies: 0
    Last Post: 03-29-2011, 04:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums