Solution: Events like On Form Exit cannot run if you are inside custom button code. If you have custom navigation buttons that change which record you are on, those buttons should also perform any tasks normally handled On Form Exit.I have been fighting an "intermittent" problem for too long! But I think I may have located the culprit.
I have code in FormName/OnFormExit that does some Audit logging. Typical lines are like this
Record = @TN(@XLR(........LastRecord +1 stuff
DateEntered = @Date
TimeEntered = @Time
AddedBy = @UserID
But I have run into instances when the code no longer worked. Double checked, triple checked syntax etc.
Commented out lines, used WriteLn to track process, etc. And suddenly it works again, for no reason. Initially I thought it was just an XLR problem, but then realized that none of the code was working.
Well, there's always a reason, and I think I stumbled across the problem tonight. I need to do more testing, but this is what I found.
If the first line of the programming section is blank, then the code does not run at all.
If I remove the first blank line, then the code runs.
I was able to fix this problem on two forms in an application by removing the blank liine.
The actual format of the programming section was a blank line, followed by a \\commented line, followed by code, like this:
// Commented line is here, followed by code. The line above is BLANK
Record = @TN(@XLR(........LastRecord +1 stuff
DateEntered = @Date
TimeEntered = @Time
.....
....
more code
.....
.......
I would like to know if anyonel elcs can duplicate this. Using version 2.0.3, and this code is in FormName/OnFormExit section. Don't know yet if it is limited to this one section, or just in this application. I know that it can be duplicated in other databases within this same application.
Also of possible importance, is that this code may have been a result of XML import. Don't think that should make a difference, but need to find out.