What layout is current when you run this script and is all repetitions of Day Number visible on this layout?
Clear only clears a field if that field is present on the current layout.
Set Field [Attendance::Day Number ; ""] can clear a field without the field being physically present on the current layout nor do you have to use go to field to place the cursor in the field, though the current layout needs to refer to Attendance in the Show Records from box in Layout Setup...
With Replace Field Contents, you can use the calculation option to clear the fields without the Clear Select and go to field steps. You can even put this script in a loop with a variable that tracks the current repetition reference instead of 31 Replace field contents steps.
Note that no part of your script is putting a "-" in the field repetitions, it's simply deleting the current contents to make them empty. Also note that Replace Field Contents can fail to work correctly if you are sharing the file over a network and there is any chance at all that another user might be editing one of these records at the time your script attempts to use Replace Field Contents. The other user will "lock" the record and you'll get an error message telling you that one of the records was not updated, but not which one it was. Thus, Replace Field Contents should not be used unless you are completely certain that no other user can edit on of the records being updated by it.
- If you can't use Filemaker Advanced, (it's debugger is well worth the extra $$), you can insert pause/resume script steps into strategic points so you can examine fields on your current layout, then you can continue the script to the next pause point and check again. You can also use Show Custom Dialog to both pause the script and display the values of fields and/or variables.
- If you want to copy and paste a script, you can copy script text from a PDF of your script using the PDF reader's text tool. With advanced you can also copy and paste script text from the Database Design Report.
Thank you very much for this helpful response! I have figured out how to use Replace Field Contents, rather than Field Select. Can you give me any pointers in putting in a loop? Specifically, how do I define the variable to track the iteration of the Day Number variable (which ranges from 1-31)?
I'd probably use a table of related records for this instead of a repeating field, but since you asked for the looping script with the repeating field...
Set Variable [$I ; value: 1 ]
Replace Field Contents [No dialog ; Attendance::DayNumber [$I ] ; ""]
Set Variable [$I ; Value: $I + 1 ]
Exit Loop If [ $I > 32 ]
This worked--Thank you so much!
I appreciate your point about better ways to do this....maybe if I ever have some free time, I'll rewrite the whole thing. But until then....