hartmut77 Posted November 20, 2003 Posted November 20, 2003 Hello I have a text string serial number which has a word "model" imbedded in each serial number. I need to replace that (word) "model" within the string to a code from another field called "code". The problem is that the word "model" is sometimes in different places within the string. for example J98(model)564790D3 K098f(model)F4FED5 In the first example it is in the 4th digit that it starts and in the second example it is in the 6th digit where it starts BUT the field code sometimes contains 3 or 4 or 5 digits so if the field "code" in the first record is "DCVRT" Then the first record should become J98DCVRT564790D3 and if the field "code" in the second record is "DCKT" Then the second record should become K098fDCKTF4FED5 Thanks Dave
ESpringer Posted November 20, 2003 Posted November 20, 2003 Use the "Position" function in your calculation: Position(Ser#,"(model)",1,1) will return the place in the serial number field where "(model)" happens -- 4 in the first case, 6 in the second. Use it within a Replace calculation to tell it where to replace the next 7 characters with Code. -ESpringer
Lee Smith Posted November 20, 2003 Posted November 20, 2003 Hi Dave, What determines the code to be used as the replacement for model. is it the leading characters, the number of characters before or after "(model)"? etc. Lee
hartmut77 Posted November 20, 2003 Author Posted November 20, 2003 Hi Lee Thanks for answering, It is already defined in another field. Sometimes it is 3 or 4 or 5 characters but it is already set in the field called "code" . I would say the number of leading characters determines where it goes. In other words, "model" will be replaced by the contents of field code. Hope that is what you are asking thanks Dave
Lee Smith Posted November 20, 2003 Posted November 20, 2003 I'm still confused. Maybe I haven't had enough coffee yet, but how are you going to know which records require which "Code". Or are you doing a find for each set of records for each code based on the other field? If so, you can change "(model)" to the Code number using a simple Replace by calculated results, either manually or by script, using a calculation that looks like this: Subsitute(YourField, "(model)", "code") A couple of things to remember. if "(model)" isn't in parenthesis than change the calculation to "model" and where "code" is, type in the applicable code number. Note: Practice with this on a copy of your file, because you can't UNDO replace. HTH Lee
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now