2 Replies Latest reply on Sep 7, 2012 1:21 PM by MorkAfur

    How to disable a field?

    MorkAfur

      Title

      How to disable a field?

      Post

      I'm on a layout that has a Yes/No radio button set.

      If the user clicks "No" for the question, I want to disable the answer field.

      While this seems like it would be an obvious script step (Disable Field[specify]), I don't see how to do this. I've seen articles written using a portal trick, but this is all in one table.

      Also, someone wrote back in 2009 about this about using Conditional Formatting to change the color of the field, but as I understand it, the user could still type into this field.

      The only other idea that was presented that I've found was to create a separate layout, one with the answer field (in this case) and one without the answer field. Then switch between the two layouts depending on what was selected in the radio button. This seems pretty cludgy since there should be a simple way to show a disabled (really disabled) field set by a script.

      What the heck am I missing? Why no simple script step to help control what users can access on a layout and what they can't.

      Thanks,

      - m

        • 1. Re: How to disable a field?
          philmodjunk

          Being able to disable layout objects would be a great new feature for FileMaker: http://www.filemaker.com/company/contact/feature_request.html

          Since you can't there are a variety of options you can try. Just because this is all in one table doesn't mean you can't use a portal. You can use a self join to link a table to itself.

          You can also use an invisible tab control to make the field disappear or you can put a copy on one panel that has a "disabled" appearance and which as field entry prevented and a normal looking editable version on the other. A script can then select the correct tab panel.

          You can also use conditional formatting to give the field a disabled appearance and then use the OnObjectEnter trigger to perform a script that checks to see if the field should be disabled or enabled. If it should be disabled, the script can use go to field, go to next field or go to object to move the focus back out of the field in order to prevent entry into the field when it is not permissible.

          Here's a demo file that illustrates a number of methods for making layout objects appear/disappear that you may find helpful:

          https://www.dropbox.com/s/8levaz6deiyzjr8/LayoutObjectVisibilityControlDemo.fp7

          • 2. Re: How to disable a field?
            MorkAfur

            Very cool info, Phil. Thanks.

            You're so quick!

            I was just getting ready to post back and say that I used the OnObjectEnter idea and it works fine.

            I'm using two triggers. One is on the "No" radio button. If they click that, then it zeros out any text entered in the answer and moves them to the next record. If they come back to that record and try to land in the answer field, then I have another OnEnter script that says: "ah ah ah, you have to change the answer to 'yes' first", then dump them into the radio button field.

            Funny business rules, I know.

            Thanks again.

            - m