4 Replies Latest reply on Jan 28, 2011 9:46 AM by mgxdigital

    Replace Field Contents

    mgxdigital

      Title

      Replace Field Contents

      Post

      I'm trying to help a friend with a problem.

      She created a shipping database and did it completely wrong. So we're trying to fix the problem.

      She has built 5 different fields for shipping when she really only needs one.

      Currently she has a field for shipping, best way prepaid, best way collect, bestway frieght, best was other shipper, fedex and ups. These are all checkbox fields by the way.

      On each record, only one of these checkboxes are marked.

      We've made a new field called carrier. Is there any way for a script or something to mark the new field carrier as whichever one of the checkbox fields has a value?

        • 1. Re: Replace Field Contents
          ryan

          Here's a rough script idea:

          Go to Record/Request/Page [First]

          Loop

          If [yourtable::oldcarrierfield = "UPS"]

          SetField [yourtable::newcarrierfield;"UPS"]

          Else If [yourtable::oldcarrierfield = "FedEx"]

            SetField [yourtable::newcarrierfield;"Fedex"]

          /* And so on and So forth...*/

          End If

          Go to Record/Request/Page [Next; Exit after last]

          End Loop

          • 2. Re: Replace Field Contents
            Sorbsbuster

            rdowler's suggestion is really clear, and that is a big plus.  If you want to do it in less (AND you are guaranteed that only one carrier has been ticked across all of the 5 fields - that's also a job for a radio button set, not a check-box, but anyways) then you could amend it to be:

            Loop

            Set Field [yourtable:NewCarrierField = OldCarrierField1 & OldCarrierField2 & OldCarrierField3 & OldCarrierField4 & OldCarrierField5

            Go to Record [Next, Exit after last]

            End loop

            • 3. Re: Replace Field Contents
              philmodjunk

              Or just use Replace Field Contents with the calculation option, using Sorbsbuster's calculation, but no script.

              With all of these approaches, make a back up copy of your file first just in case you don't get the results you expected.

              • 4. Re: Replace Field Contents
                mgxdigital

                Woohoo!  Thanks everyone! This worked perfect.