5 Replies Latest reply on Nov 24, 2009 1:27 PM by philmodjunk

    LOCKING FIELD

    DimVas42

      Title

      LOCKING FIELD

      Post

      HOW CAN I  PREVENT THE MODIFICATION OF A FIELD WHEN IT ISN'T EMPTY?

        • 1. Re: LOCKING FIELD
          ninja
            

          Howdy DimVas42,

           

          I haven't tried this, but the concept seems to make sense early in the morning...

           

          Make the field a button (Button setup...) and have it perform a script:

           

          If (Table::yourfield = "")

               GoToField (Table::yourfield)

               Exit Script

          EndIf

          Commit record

           

          That way if the field is empty, it sticks the cursor in the field for data entry.

          If it isn't empty, commiting the record puts the cursor back outside the field to prohibit data entry/modification.

           

          FMP doesn't have field level privileges by calculation, although I truly wish it did.  Maybe later...maybe already in FMP10?  Anybody?

           

          I'll mock this up later on today to check it out.

          • 2. Re: LOCKING FIELD
            ninja
              

            Mocked it up today,

             

            It works fine, though I used If( Isempty(Table::field) ) instead.  Be careful, though, it locks everybody out of that field once there's data in it...even folks who might be allowed to change the data.

             

            You can get around the lockout by:

            1. having the field on a different layout too, with access privileges on the layout where a 'privileged' person can modify the data (preferred method)

            2. unclipping the button setup, changing the data, reattaching the button setup (a lot of work for a field update and makes the field modifiable to all while you're doing it)

             

            Hope this works in your application.

            • 3. Re: LOCKING FIELD
              philmodjunk
                

              Ninja, there's gap in your armor here (That's why access privilege based security is so much better, but as you've said settings at that level enable you to lock the record instead of just the field.)

               

              If the field is part of the layout's tab order, you could still tab your way into the field and modify it. If you use his approach, be sure to remove the field from the tab order.

               

              Other options:

               

              In FMP 10, this can be a script trigger set to execute Ninja's script when the field is entered.

              Redesign your tables so that this field is in it's own/related record, then access privilege based record locking can be used after all.

              • 4. Re: LOCKING FIELD
                ninja
                  

                Good call, Phil.

                 

                Thanks for pointing out the gap with something less than an arrow.

                 

                Short of a script trigger (as I'm still on FMP8&9, 8 mostly) is there another way to (get/set/pretend at) Field level privileges?  I look for that tool constantly, but it's never there in my FMP8 toolbox.

                • 5. Re: LOCKING FIELD
                  philmodjunk
                    

                  Well, you can simply remove the field from the tab order so that it can't be entered that way. :smileywink:

                   

                  Or, as I've mentioned in my last post, you can divide your record into two parts in two different tables with a one to one relational link.

                  One part would contain the fields you don't want to lock in this way. The other would contain the field or fields you do want to lock. Now you have a single record that you can lock via the standard Access privileges.