You have more than one problem
The error message indicates that the attempted field reference that triggered it refers to a field that is neither global nor from a related table occurrence. If this is a reference to a field in your globals table, I suggest checking storage options on that field as it appears that global storage has not been specified for it.
But your case function will not work reliably. To understand why, make a copy of your check box formatted field next to the check box formatted copy, but return it's format to "Edit box" configuration. Now click different check boxes and in different orders and note what appears in the edit box. Note how the order in which you click check boxes affects the order of the values that appear in the edit box formatted copy.
The solution is to use the FilterValues function to check to see if a particular value is selected.
Then you have the problem that the second part of your case function cannot be used to assign a value to a field. mytable::name="" is a Boolean expression that returns 1 (True) if the name field is equal to an empty string and 0 (False) if it is not.
You'd need to use a series of IF steps in a script rather than a single case function in a calculation. The first would look like this:
If [ IsEmpty ( Filtervalues ( Globals::whichchk ; "name" ) ) ]
Set Field [ mytable::name ; "" ]
But if the values in your check box value list are exactly the names of your fields, you could also use this script:
Set Variable [$K ; value: $K + 1 ]
Exit Loop If [ $K > valuecount ( Globals::whichchk ) ]
Set Field By Name ["mytable::" & GetValue ( Globals::whichchk ; $K ) ; "" ]
But make sure that whichchk is truly a field with global storage specified or none of the above will work.
First of all, you understood my problem correctly even though I thought I was not able to express it clearly.
Yes, I had not defined globals::whichck with Global Storage – (Common sense but it flies out of the window when under pressure)
I learnt something new when I created an edit box of the globals::whichck, right next to
globals::whichck formatted as a value list.
I saw that the edit box showed the fields I had check marked not ( 0 or 1 for each field that I selected) as I had thought.
Thanks. I had never thought of seeing a value list based field as an edit box.
Also, thanks for the loop statement that taught me how to make it generic.
There is a lot to learn but your prompt reply taught me a lot.