Nothing obvious jumps out at me as wrong. A few questions/comments though:
Is Previous UPN a global field? If not, it should be.
Is Previous UPN on the current layout? Since you use a Clear script step, the field must be present on the current layout in order for Clear to clear the field.
If you used Set Field ["Previous UPN", "" ] instead of Clear, this is no longer necessary.
Here's how to do it via a relationship & 2 calculation fields:
- Relate the file to itself, based on your key field, called "Self" (Unique Part Number in your example, I believe)
- create a calculation, "record_id" = Status ( CurrentRecordID )
- create another calculation, "master" = Case( Status(CurrentRecordID) = Self::record_id, 1 )
Anytime the "master" field contains a 1, it is the master record based on your related field.
There is a flaw in your logic. Consider the sequence of records A,A,B,B. The loop starts on the first record.
First loop: If returns false, global is set to A and goes to next record (found set A,A,B,B; global=A)
Second loop: If returns true, record is omitted (found set A,B,B; global=A)
Third loop: If returns false, global is set to B and goes to next record (found set A,B,B; global=B)
Fourth loop: If returns true, record is omitted (found set A,B; global=B)
Fifth loop: If returns true, record is omitted (found set A; global=B)
Sixth loop: If returns false, exit loop since it is the last record (found set A; global=B)
So the problem occurs in the fourth loop. But the only way to exit the loop is when the global does not match the current record.
I don't have FileMaker Pro 5.5 handy so I can test a solution with the scripting available in that version. We would do this with different techniques in the current version.
TS_Oz, FileMaker Inc.
Ts_Oz: So if I'm understanding what you're saying, the omittance of the last record and the subsequent move to the "now" last record (which is the previous record) causes the loop to re-iterate. Then of course they match and *poof* there it goes. I get it.
Hmmm...well, I'll go back to the drawing board and let you know how I fix it.
Note to all (especially PhilModJunk, who has been my sounding board for some time now): I just submitted a proposal to upgrade to version 11. Keep your fingers crossed...I know I am.
Thanks again for everyone's input!
I'm trying to integrate
Exit Loop If ["Status(CurrentRecordNumber) = Status(CurrentRecordCount)"]
with little success. I put it after Omit Record as well as after End If and neither solves the problem. Perhaps my logic statement isn't written correctly?