4 Replies Latest reply on Feb 23, 2011 9:46 PM by LanR

    Find/Replace script won't work

    LanR

      Title

      Find/Replace script won't work

      Post

      This should be simple, and I searched and read the few message threads with this problem and none of the answers did anything.

      I need to replace the last five characters from a field's contents with other characters. Creating a script using Find/Replace function doesn't work. I've tried all sorts of combinations of Direction Forward or All, All Records/requests and just Current record just to get it to work on the present record, but nothing happens, except with some of those settings it does select the last five characters.

      Generally, if I run the script, then go to Edit menu and select Find Next it will replace the characters in the current record, then just sit there. Or if I select them first, it will then replace them.

      I've added and tried other script steps such as Enter Browse Mode, Find Mode, etc. None of it matters.

      Also, what function or process would be used to do this same type of thing, only remove some characters, that is just cut them off the end of a word, or a space and the last word in a field (Find/Cut not Find/Replace)?

      Thank you,

      LanR

        • 1. Re: Find/Replace script won't work
          philmodjunk

          Perhaps you should try Replace Field Contents instead of Find/Replace if you are attempting to modify a single field across all the records in your found set.

          • 2. Re: Find/Replace script won't work
            LanR

            That won't work, the field contents are all different, but do have the same ending.

            I don't understand why it won't work; this looks so simple. I've looked through some of my other databases and have found that I've used this script before with success. I copied one over to this script, changing the search and replace characters of course, but nothing happens. It works in the other database, not in this one.

            LanR

            • 3. Re: Find/Replace script won't work
              philmodjunk

              Even when the field contents are all different, you can still use Replace Field Contents with the calculation option.

              Example

              Say the field is called: YourTable::TextField and you want to change the last 3 characters of this field to YYY for every record in your table:

              Show All Records
              Replace Field Contents [no dialog; YourTable::TextField ; Left ( YourTable::TextField ; Length ( YourTable::TextField ) - 3 ) & "YYY" ]

              Whenever you are testing Replace Field Contents, it's a very good idea to save a back up copy just before trying it out as you cannot undo.

               

              • 4. Re: Find/Replace script won't work
                LanR

                Hi Phil,

                Thank you for the help. This Replace Field Contents works. Does the trick. Also thanks for the reminder about backing it up first, turned out to be a wise move! Now it works correctly.

                Problems solved.

                LanR