9 Replies Latest reply on Dec 17, 2010 4:25 PM by philmodjunk

    Disable a drop down field depending on the value in another field.

    KingsPawn

      Title

      Disable a drop down field depending on the value in another field.

      Post

      Newbie

      FM9 PRO Advanced

      Microsoft XP

       

      I have a drop down field that I would like to disable depending on the value entered in another field.

       

      I have a drop down field with conditional formatting if Global Variable = 0 hide it by setting the fill color the same as the back ground and setting the pen color the same else set it to show.

       

      Setting on top of the drop down field is another field that points to the same field in my table. This field has conditional formatting if Global Variable = 1 hide it by setting the fill color the same as the back ground and setting the pen color the same else set it to show.

       

      Works nice.

       

      BUT if you click on the area where the hidden drop down field is it displays and allows you to modify the value.

       

      How do I disable data entry in a drop down field depending on values in other fields?

       

      If I could uncheck the box (In Browse mode) in Field behavior dialog box from a script it would do the job.

       

      Any hint would help:smileyvery-happy:

        • 1. Re: Disable a drop down field depending on the value in another field.
          Jade
            

          Hi KingsPawn,

           

          When you define the drop-down field (Manage>Database… ), click the Options button and set the Validation option to Validate by calculation.  In the specify dialog check that the global variable is not equal to 0.  Also deselect the 'Allow User to override' checkbox. 

           

          There is also a way to do this with the user's Privilege Set that is described here:

          http://forum-en.filemaker.com/fm/board/message?board.id=FM-en-4&message.id=8174#M8174 

          • 2. Re: Disable a drop down field depending on the value in another field.
            KingsPawn
              

            Jade,

             

             

             

            I did not state in the original post that the drop down field is TEXT.

             

            In the Manage>Database...

            I clicked the Option Button and set the Validation option to Validate by calculation.

            I deselected the ‘Allow User to override' check box.

            So far so good.

            I just don't understand what you mean ...

            'In the specify dialog check that the global variable is not equal to 0.'

            I thing I know what the ‘specify dialog' is. It is a dialog box that allows you to create a calculation where somefield is = to that calculation.

             

             

            Is the Global Variable you are talking about the one I said I was using in my ‘conditional formatting'?

             

            I really need some help on this one.:smileysad:

            • 3. Re: Disable a drop down field depending on the value in another field.
              Jade
                

              KingsPawn wrote: 

              …I clicked the Option Button and set the Validation option to Validate by calculation. 


               Good.  Next to the "Validated by calculation" there is a "Specify…" button.   Click this button and the "Specify Calculation" dialog box opens.  Your cursor should now be in the "Validation for field …" box.  This is the 'specify dialog' that I mentioned.  Enter the conditional test here:
              $$yourGlobal ≠ 0 
               

              KingsPawn wrote:

              …I thing I know what the ‘specify dialog' is. It is a dialog box that allows you to create a calculation where somefield is = to that calculation. 

              Is the Global Variable you are talking about the one I said I was using in my ‘conditional formatting'?


                      Yes.  

               

              The validation will prevent a user from changing the drop-down field value when your Global Variable is set to 0.   But it will not prevent the drop-down from showing if the user clicks it.  

               


              • 4. Re: Disable a drop down field depending on the value in another field.
                KingsPawn
                    Jade, 

                This code does what is needed but at first it appears as though you would be able to modify the drop down field. Then when you try to move off this record the system displays an error dialog box stating that you must revert all changes to this record since it was last entered. And will not let you do anything until you do revert it. 

                This will do the job very well, although I would have preferred to be able to just disable the drop down field.  But like I stated it does do the job so lets just get on with other more pressing problems.

                 

                I would like to take this time to thank you from the bottom of my heart for the help and guideance you have given me. I look forward to the day when I will be able to help others.

                 

                I remain, just piddlin in the past.

                 KingsPawn:smileyvery-happy:
                • 5. Re: Disable a drop down field depending on the value in another field.
                  Jade
                    

                  Hi KingsPawn,

                   

                  Yes, I agree; it is not an elegant solution.  Perhaps when you have more time, you can describe why you are hiding these fields and what you are trying to achieve.  That way others may be able to suggest a better approach.  

                   

                  So, we'll leave this thread open… 

                  • 6. Re: Disable a drop down field depending on the value in another field.
                    philmodjunk
                      

                    Two "less awkward" solutions.

                     

                    Upgrade to FMP 10 and use a script trigger that performs a script to check your "lock" field when the field is entered and moves them back out of the field if it is locked. You can set this script to display a message "this field is locked" or such if you want.

                     

                    In 9, it's a little less elegant:

                    Take the field out of the tab order so users have to click on the field to enter it.

                    Use Field / Control | Behavior to uncheck the "allow field to be entered in browse mode" check box.

                     

                    Create a script:

                     

                    If [value in lock field shows lock status]

                        Show custom dialog ["Field is locked"]

                    Else

                        go to field [TableName::dropdownmenufieldname]

                    End If

                     

                    In layout mode, click on your drop down menu field and set it up as a button.

                    Set it to perform the above script.

                     

                    That should do it.

                    • 7. Re: Disable a drop down field depending on the value in another field.
                      SteveWehba

                      It's a very common need to enable/disable and/or show/hide one field based on the status of another field or set of fields. For instance, if one field lets you set gender ("Male" or "Female"), another field "Number of pregnancies" would appear only if "Female" were selected. (OK, it's a bad example, but you get the picture.)

                      I can't believe that FileMaker does not natively support enabled/disabled and visible/invisible properties of fields. Even — God forbid! — MS Access supports this.

                      • 8. Re: Disable a drop down field depending on the value in another field.
                        Kekova

                        I am a beginner and I was trying to figure out a way to disable a field based on certain conditions. For example, as Steve mentioned, you may want to disable the "Number of Pregnancies" field if the selected gender is male. Here is a potential simple solution:

                        First, create a script that kicks in once someone enters the field you want to disable (use OnObjectEnter):

                        If (Gender = Male)

                            GoToField [some other field]

                        End If

                        If gender is male, this script will not let you in to the pregnancy field.

                        Second, create conditional formatting using the same condition: if the gender is male, gray out the pregnancy field. This will effectively disable the field.

                        I hope this helps.

                        Right after I wrote this, I realized that PhilModjunk already answered this question in Feb 2009. Proves that if you can't find an answer, just read again because someone must have answered it before.

                        • 9. Re: Disable a drop down field depending on the value in another field.
                          philmodjunk

                          A few things learned since then:

                          OnObjectEnter won't work if the field is formatted as a drop down. A bug in FileMaker keeps the trigger from firing until after you select a value from the drop down.

                          Also, a conditional format color change only helps tell the user the field is disabled. If this is the only thing you do, it's still accessible.

                          You can also put the field in a related table with a one to one relationship, and then use record level access controls in Manage | Security do deny access to this related table with an expression that references your "lock" field. This is the most secure way to prevent edits of this field as this locks the user out on all layout's in your system.