3 Replies Latest reply on Oct 5, 2013 1:03 PM by philmodjunk

    Toggle a field between records

    johnw54

      Title

      Toggle a field between records

      Post

           Is there a way to toggle a field on/off to allow only 1 record to have it on.

           Currently using the following sctipt

           Show All Records

           Replace Field Contents (no Dialog;Products::DB Catalog:"")

           Set Field (Products::DB_Catalog;"Yes")

           This works to make a new selection and turns off the old.  But I need to able to have no selection at all.

        • 1. Re: Toggle a field between records
          philmodjunk

               You can do it with a global field and/or a relationship, but the implementation details can vary depending on the design and usage of your database.

               Is this database hosted over a network?

               Is this a database that has multiple users and the "on/off" value must be the same over all users or might each user need a different record selected in this fashion?

                

          • 2. Re: Toggle a field between records
            johnw54

                 This database is a stand alone system.  Only 1 user.  Any suggestions would be appreciated.

            • 3. Re: Toggle a field between records
              philmodjunk

                   You need a primary key in this table. Let's assume that it's named: Products::__pkProductID.

                   Define a field with global storage named Globals::gSelectedProductID

                   replace your "yes" field with a button with this one line script:

                   Set Field [Globals::gSelectedProductID ; Products::__pkProductID ]

                   You can set up a single character block of layout text with a conditional format both as your selection button to perform this script and as the indicator that shows which record is currently selected. The conditional format can render the text invisible when the global field and the records ID are NOT equal. If that character is the letter x or a "tick mark" character with a rectangle behind it, this can create the look and feel of a check box, but selecting one record will automatically clear the previous choice.

                   Ps. you may need Refresh Window [] to get the conditionally formatted text to update. And there are other conditional format options, such as one that highlights a field or fields in the record that can be used to show which record is selected.