3 Replies Latest reply on Oct 17, 2008 4:29 AM by AndreasT

    Choose value from one of 2 fields

    icaxap

      Title

      Choose value from one of 2 fields

      Post

      Hi!

       

      I,m trying to create a value list (or, this is a wrong way to do this maybe).

      I have a table with clients. Each client have 2 addresses - office (first field) and home (second field).

      To create delivery record for each client I have to choose at another layout which address to use for delivery - office or home. And then this address should be saved to delivery_address field in the table with inforvation on delivery terms.

       

      What is the best way to do this value list (or any other script/trick) to choose from 2 variants stored in 2 fields? 

        • 1. Re: Choose value from one of 2 fields
          AndreasT
             You can very well use a value list for the selection method, but you need a bit more logic to fill inn the selected address in you delivery address.

          Make your value list with the values Home and Office.

          assign this value list to a text field, n the example I have named it Choose_del_addr

          Assuming the delivery address is a text field, set up an Auto Enter calculation under Options for that field.
          Set you calculation up like this:

          If ( Choose_del_addr="Home" ; Home address ; Office address)

          Press ok and uncheck the mark at "Do not replace existing value of field"

          Repeat as necessary for the other address fields.

          That should do it.
          • 2. Re: Choose value from one of 2 fields
            icaxap
              

              Thanks!

             

            Sometimes we should fill in delivery address in the delivery table (layout) manually.

             

            So, shuld I use in this calculation IF or CASE operator. Or it doesn't matter?

            • 3. Re: Choose value from one of 2 fields
              AndreasT
                
              Yes, you can enter data manually, thereby overriding the calculated results as long as you are using a text field with Auto Enter and not a calculation field.
              If you after entering manual data choose the other option form the popup, your manual data will be overwritten by the calculation.
              (Because we unchecked the "Do not replace existing value of field" button in the Auto Enter options. Check this button to preserve already entered content.)

              Using IF or CASE is mostly a matter of preference.

              I mostly use CASE statements, but many find IF easier to understand at first glance for the simpler statements. For complex nested statements, IF gets unwieldy and I would recommend sticking with CASE.