Jump to content

Conditionally prevent edit of field contents


This topic is 2861 days old. Please don't post here. Open a new topic instead.

Recommended Posts

This must be easy to do, but I just can't think it through.

Suppose Field#1 contains the value "Yes".

Then I want to allow a user to edit "Yes" to "No".

But if Field#1 already contains "No", then I want to prevent this being changed to anything else.

I'd like to do this with minimal overhead - preferably no Script Triggers or buttons or dialogues - it should be seamless. i.e. if the user overwrites "No" with "Yes", it should revert back to "No" with no dialogue.

Is this possible ?

Thanks for your time.

Link to comment
Share on other sites

I feel like this is a very common desire, but Filemaker doesn't have an easy way to accomplish this...

 

Is your case simply that one field Yes/No field?? You should just use some script triggers...Store the current field value on field enter To a $$Global Variable or a global field. Then, on field exit, have another script trigger, if Previous Value = "No" and Field1Value = "Yes"; Field1Value = "No". Each script would be a couple of lines. If you wanted you could show a dialog sending a message about reverting the field.

Link to comment
Share on other sites

@hbrendel....could we see your 'easy way'?  I tend to overcomplicate things.

I came up with this script trigger for OnObjectModify, Script parameter is just the field

 

Set Variable [$$a; Value:Get(ScriptParameter)]

If [isEmpty ($$a) or $$a="Yes"]

Else

     Set Field [Table::field;"No"]  // Yes/No field

End If

Set Variable [$$a; ""]

 

I put this on a radio button set.  In this field I use RayBaudi's (where's he been?) much posted:

GetValue (Self; ValueCount (Self)) as an auto enter calc, "do not replace..." unchecked, to prevent shift+clicking both buttons

Link to comment
Share on other sites

I use 'Hide Object When'.

Make two instances of the same field, One is editable, the other not. Give them complementary conditions for hiding and place them on top of each other.

The non-enterable field is hidden when the value not = "No".

The enterable field is hidden when the value = "No".

Easy in FM 13...

  • Like 3
Link to comment
Share on other sites

But if Field#1 already contains "No", then I want to prevent this being changed to anything else.

I'd like to do this with minimal overhead - preferably no Script Triggers or buttons or dialogues - it should be seamless. i.e. if the user overwrites "No" with "Yes", it should revert back to "No" with no dialogue.

 

I think the question of why you want this should come before the question of implementation costs. If this is a matter of data integrity, then it should be solved at the data layer, not by using any layout measures (script triggers, conditional formatting, etc.).

 

 

Are you really using version 7 as indicated by your profile?

Link to comment
Share on other sites

This worked perfectly for my case, thank you! Very cool, I hadn't seen Hide Object When..

 

I use 'Hide Object When'.

Make two instances of the same field, One is editable, the other not. Give them complementary conditions for hiding and place them on top of each other.

The non-enterable field is hidden when the value not = "No".

The enterable field is hidden when the value = "No".

Easy in FM 13...

Link to comment
Share on other sites

This topic is 2861 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.