3 Replies Latest reply on Aug 22, 2016 9:31 AM by dsnider

    Replace lots of records at once

    garonson

      Title

      Replace lots of records at once

      Post

           A field may have only one of two values (1 or 2).  Only one record in the table may contain a 1.  User changes a 2 to a 1.  How do I in a script sense that change and change all other records in that table to a 2?  Note a 1 is a yes and a 2 is a no.  Only one record (A user) can be a yes (be the system default user).  I must programmatically assure this.

           Now its time for the experts to suggest just how to do this.  Please help.

        • 1. Re: Replace lots of records at once
          philmodjunk

               Two options suggest themselves:

               Since only one record can have the value of "1", you need only use a scripted find or relationship to find the record with this value and change the field's value to 2 just before you change the selected record to 1. This can be done by changing your yes/no field into a button so that clicking it performs a script that changes the original record to 2 and then changes the selected record to 1--which updates the field so that a check box or radio button format will also update just as though the user clicked the field.

               or:

               Change your structure so that this value is a calculation field or even a conditional format controlled layout object that is set up as a button. When the user clicks to make the selected record "yes", the script changes the value of either a) a global field, or b) a global variable or c) a field in a related table that is linked by Cartesian Join operator (x) to store the value of the primary key of the selected record. The calculation field or conditional format then compares the records primary key to the value in this field or variable in order to show a value of "yes" or "no". Changing the value of this field or variable then automatically changes the value displayed on the previously selected record from "yes" to "no".

               Note that this second option can allow you the option of having multiple users that each have a different records selected as "yes" if you find that capability useful to what you need to have happen in your database.

          • 2. Re: Replace lots of records at once
            garonson

                 Wow, faster than an eagle flies.  I will review and attempt to apply.

                 Gordona

            • 3. Re: Replace lots of records at once
              dsnider

              I know this is an old thread but I was wondering if you had an example of this script.  I haven't been able to make this work. Thanks!