You'd have to trap each of the events that "Exit" the record:
Closing the window (OnWindowClose in file options)
Changing layouts (OnLayoutExit )
Going to a different record in the same layout (OnRecordLoad)
To keep from processing the "exit" more than once, you'd need to experiment with setting a value in a global variable when you first put the focus on the record or open it for editing (onObjectEnter on a field) that you then clear the first time you process the "exit".
so I wouldn't be able to use the field that currently counts up each time I sent an eletronic copy? Figured: If (ElectronicCounter < 1) would be enough to signal that the accounting departement had note recieved a copy.
I'm guessing that by the time OnRecordLoad kicks in it will no longer have access to the original counter?
That's why you need to capture the primary key of the current record in a global variable with each OnRecordLoad event. The script has to both check for the ID of a previous record and also save the value of the current record. The other script triggers would simply clear the variable once they have processed the "exit" event.
I can't use validation because certain fields require that the record be committed before applying the appropriate calculations therefor I keep getting validation messages every time I try to navigate through the fields.
Hmm, what that has to do with this issue is not at all clear to me here, but you might consider experimenting with the onObjectValidate event to capture and process validation issues before the field based data validation can kick in.
So If I'm to take the global variable route, how would the script look like? For some reason I'm drawing a compelte blank.
I have a primary key field called InventoryADJID and ElectronicCounter which is the field that counts how many times an electronic copy has been sent to the accounting department.
There would be one script for OnRecordLoad and a different script for the other triggers. I'm going to change the original idea by saving the record number rather than the primary key--though the key could be used instead with the right self join relationship
If [ Not $$TriggersOff ]
If [ $$PreviousRec ]
Set Variable [$$TriggersOff ; Value: True ]
Set Variable [$Current ; Value: Get ( RecordNumber ) ]
Go to Record/Request/Page [$$PreviousRec ; no dialog]
#Do whatever you need to do on the exited record here.
Go to Record/Request/Page [$Current ; no dialog]
Set Variable [$$TriggersOff ; value: False ]
Set Variable [$$PreviousRec ; value: Get (RecordNumber ) ]
$$TriggersOff is a variable that I am using to keep this script from tripping its own script trigger in an infinite loop of tripped script triggers. THe script for the other triggers would be nearly the same but the last Set Variable step would set $$PreviousRect to "" to clear the variable.