1 Reply Latest reply on Jul 29, 2010 11:10 AM by philmodjunk

    Lock button with changing icon to lock and unlock fields



      Lock button with changing icon to lock and unlock fields


      Again, I think there may be an answer out there for this...

      Running Filemaker Advanced...

      I wish to add a small button on a layout that when clicked, will lock four fields.  When clicked again, it will unlock the four fields.

      Of course is would be better if an icon on the button changed from a picture of an unlocked padlock to a locked padlock as well....

        • 1. Re: Lock button with changing icon to lock and unlock fields

          To get an icon to change, use a calculation field that returns "container" as it's return type. Load your two images into two container fields or two fields of a related record related to your current table with the X operator so that the values are linked to all records.

          Set up an expression in your calculation field like this:

          If ( gLockField ; LockImageField ; UnLockedImageField )

          Set up the calculation field on your layout as a button to perform this script:

          Set Field [ YourTable::gLockField ; Not YourTable::gLockField ]

          gLockField would be a global number field.

          To "lock" the records, you have two basic options: On the layout, you can use OnObjectEnter Script triggers to run a script that checks the value of gLockField and uses Go To Field or Go To Object to put the cursor or focus somewhere "safe". This "locks" these fields only for the layouts where you set this up.

          If you can put all four fields in a related record separate from the other data you don't want to lock, you can use gLockField for record level access controls set up in Manage | Security. This locks an entire record for all layouts in your database. To learn more on this, see "Editing Record Access Privileges" in filemaker help and scroll down to the section titled "Entering a formula for limiting access on a record-by-record basis".