Is this all in one file or is the Quantity4Labels field in a different file?
Do you have a copy of FileMaker advanced?
Any chance that you have gQuantityAdd fields defined in two different tables?
It is all in one file and in one table.
Yes, I have FileMaker advanced.
gQuantityAdd is only defined in this table.
Set Field [table::Quantity4Labels field ; table::gQuanityAdd ]
Should do the job and won't, by itself change the value of gQuanityAdd.
Good to see you have advanced. If you have not already done so, enable the script debugger and the data viewer, then run your script and watch the value of gQuanityAdd change as you step through the script step by step. At the very least, this should tell you exactly when the value changes to zero. If there's a script trigger firing a script that changes the value, you'll see it appear. This will likely show you why the value is changing back to zero when you didn't want it to.
Thanks to the advanced features, I see what is happening... but don't know how to fix it.
I have a script trigger set up for "on save" to run the script. All of it is working right, but when it goes back to reset the gQuantityAdd to "0", is saves the record and then runs the script again. For some reason it is only looping once, but that is enough to reset my Quantity4Labels as well.
There are two tricks to keep a script from triggering other scripts while it executes:
1 ) Simplest method is to create a second layout that refers to the same table occurrence as the one you are now using. Have your script select this layout to do any data changes and as it does not have any triggers defined, none will fire. This can be a blank layout. As long as it lists the same table occurrence in Show Records From on Layout Setup... it should function the same.
2 ) In your script use a global variable to disable all triggered scripts. In your triggered scripts, enclose the record in an If step like this:
If [ Not $$TriggersOff ]
//script steps go here
In the scripts that need triggers disabled, put these steps in place:
Set Variable [$$TriggersOff ; Value: True ]
// rest of script goes here
Set Variable [$$TriggersOff ; Value: False ]
If your script has multiple exit points due to Halt script or Exit script steps, you should precede each with that last step to disable your triggered scripts.
Thanks! The second layout trick did the job. The Quantity4Labels is maintaining their values. This has led to another problem upon printing the labels, but I put it in another post because I couldn't get the image uploaded on this one.
Sorry for all the trouble, but you have helped tremendously. Thanks again!