There are two parts to this problem: The color change and preventing the user from modifying the field. Conditional formatting can be used to change the color. That shouldn't be a problem for you, but let me know if you don't know how to set that up.
For the "lock" you can use the on ObjectModify script trigger like this to "lock" the field:
On the Extent field, use this script:
If [YourTable::extent = "none" ]
Set Field [YourTable::Amount ; "" ]
Set Field [YourTable::Color ; "" ]
Then use OnOBjectModify on both the amount and color fields to runt this type of single step script:
Set Field [YourTable::Amount ; "" ]
Ok great, thanks!
I've actually never used a script before. I know I go into "Manage Scripts" and create a "New Script" but I'm lost from there.
Designing a FileMaker Database without being able to create scripts is like rowing a boat with only one oar....
The available script steps are on the left. Double click one to add it to your script. You can drag the added steps around if you need to change the order.
After you have added a script step, there are options for you to specify to fill in the needed details. Some steps--such as the IF step can be double clicked to open a dialog for adding the needed details. Others show controls at the bottom of the script editor when you click a step to select it.
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
Is there any way to actually lock a field and not create blank data? I have another field where I would like it to lock from being modified after I've finished entering data.
This is all part of a datasheet that I'm creating. I've looked over the scripts for buttons, is there a way to make the data sheet so it can't be modified after a button is clicked?
These scripts do not create "blank data"--which is a contradiction in terms, BTW. They may erase existing data as I have assumed that if you select a value in field 2 or field 3, then change your mind and select "none" in field 3, these fields should be cleared.
is there a way to make the data sheet so it can't be modified after a button is clicked?
If the user does not have the file open with a full access password, settings in Manage Security for their privilege set can deny edit access to the record if a value in a particular field is set.
See "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a description of how to set this up.
Ok great! Thanks!
Hopefully this is my last question. I've created another script where if I choose an option in a drop down menu it populates values for a few other fields with "N/A." However, if I choose another value from the drop down value I'm not able to change the fields that are automatically populated. I tried the suggestion from a couple comments above using "" but that just takes the "N/A" out and does not allow me to enter in new data. Thoughts?
Set Field [ YourTable::Field ; "new data" ]
Will replace all the data in YourTable::Field with the text "new data".
Ok I tried that on one field and it still does not let me change it from "new data" to what I want to enter.
It would appear that your script is doing exactly what you have designed it to do--even if that may not be what you want it to do.
From your screen shots it would appear that four fields are at issue here:
Discharge, Uncertainty, total velocity and total area
Yet only discharge has a set field step that might possibly set the field to any value other then "N/A"
And that will only happen if Meter Type--a field not visible in your screen shots has a value of "FlowTracker" or "Pygmy".
I didn't change the four fields because I wanted to see how your idea would work with discharge first.
Meter Type is synonymous with the field "Meter Used" in the screen shot.
My problem right now is that even though discharge is set to say "new data" it does not allow me to change it from saying that.
How do I get that field to accept data if I changed the meter from "Stage QM only" (where I have the script set to automatically fill in "N/A") to FlowTracker (where I want all the fields to appear to their original view so that I can enter in data)?
You'll need to explain what you mean by that. Set field puts data in a field that is produced by a calculation. That calculation can refer to quoted text, data in a variable, data in one or more fields or some combination of all of these.
How do I get that field to accept data if I changed the meter from "Stage QM only"
Simply typing data in that field ( or selecting from a value list ) should not be a problem. Is that what you want or do you want the script to change the data?
To rephrase the question, If you change the meter type to "FlowTracker", what should happen next?
Does the user then need to enter data into the field? Does a script enter data into that field? Or does an auto-enter field option auto-enter data from another table into this field?