Jump to content
Sign in to follow this  
pomilpetan

block a field with variable

Recommended Posts

Hello to all,

I have a database and I want to block modification of the fields if a given variable is not = 1. can i do this?

i have create a button that change the variable from 0 (non modifiable) to 1 (modifiable) but if the variable is 0 i want that fields are only reading.

i use Filemaker Pro 15 for mac

thanks

Andrew

Share this post


Link to post
Share on other sites

Hi Andrew

You can set OnObjectModify (and OnObjectKeystroke if you like) Script Triggers on the fields that you want to lock, to run a script along the lines of the below. That will reject the input if the $$lockvariable is set to 0

If [ $$lockvariable = "0" ]
Exit Script [ Result: 0 ]
End If

As an extension, in one of our solutions we show an error panel, that is just a rectangle with some text in it that is the frontmost layer of the layout, and we use an OnTimer script to hide it after a couple of seconds. This explains to the user why their input is not appearing, but doesn't require them to acknowledge it.

If [ $$lockvariable = 0 ]
Set Variable [ $$showInputError; Value:"Y" ] // the $$showInputError variable is used to show/hide the rectangle with text in it
Install OnTimer Script [ “Clear Input error”; Interval: 2 ]  // this script sets $$showInputError back to 'N' after 2 seconds, which hides the rectangle again
Refresh Window
Exit Script [ Result: 0 ]
End If

The 'Clear Input Error' script needs to both change the variable $showInputError back to "N" and stop the OnTimer script otherwise it keeps running every 2 seconds. That script looks like this.

Set Variable [ $$showInputError; Value:"N" ]
Refresh Window
Install OnTimer Script [ ]

Hope that helps

Edited by rwoods

Share this post


Link to post
Share on other sites

Hello. I tried to follow your example and I managed to set up the script.

Thanks again.

Share this post


Link to post
Share on other sites
11 hours ago, pomilpetan said:

I want to block modification of the fields if a given variable is not = 1.

The simple method would be to allow users to edit records only when the variable = 1 (in users privilege set). However, I would ask why you need this - because any limitation that depends on the value of a variable can be circumvented by the user.

Share this post


Link to post
Share on other sites
12 hours ago, comment said:

The simple method would be to allow users to edit records only when the variable = 1 (in users privilege set). However, I would ask why you need this - because any limitation that depends on the value of a variable can be circumvented by the user.

The person who asked me the database has noticed that often unintentionally wrote in the fields instead of doing a search or changed field by deleting the content. so at least you can only read without changing the data unless authorized to do so.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    arni 
×

Important Information

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