Procedure Executing in Wrong Field



I’m coming from the Panorama Sheets side, so that I’m way behind the rest of you. Sheets fit my purposes, but since it is going out the way of Panorama 6, here I am trying to swim on the Panorama X side of the pool.

In any event, now, with Panorama X, I have the opportunity to add some automation to my formally Sheets databases, but I’m having an issue with my first simple attempt that is not making sense to me. I set up a procedure to run in one field, but it is running in a different field.

I have a database with the following seven fields:

Date, Name, Description, Debit, Credit, RunningBalance, Balance

The database has one procedure named “Recalculate RunningBalance” with the following code:

field RunningBalance
formulafill Credit-Debit

The only field to have any code attached to its field properties is the field RunningBalance. The code in the RunningBalance field is:

call "Recalculate RunningBalance"

My problem is that when I add a new record the procedure “Recalculate RunningBalance” seems to be operating on the Balance field, rather than on the RunningBalance field. Upon tabbing to the Balance field, the result of Credit-Debit is entered and the running total for Balance is calculated. Nothing is appearing in the RunningBalance field. The Balance field is supposed to be a constant and has no formulas or code entered in its properties. However, when I run the procedure “Recalculate RunningBalance” from the Action menu, it does properly update the RunningBalance field.

I must be doing something silly, but I just do not see it.



Take this code out of the RunningBalance field and place it both in the Debit and Credit fields. Code entered into the field’s code panel executes when leaving the field and not when entereing.


Thank you for the suggestion.

I moved the statement to the Debit and Credit fields, but the behavior has not changed. After entering a value in the Debit or Credit field, the procedure is still acting on the Balance field rather than on the RunningBalance field.


Ok, try this in each of the code sections for both the Credit and Debit fields:

field RunningBalance
field Balance
formulafill Credit-Debit


I just exported all of my records into a CSV file and then created a new Panorama X database file from that CSV file. I reentered the “Recalculate RunningBalance” procedure and placed the call "Recalculate RunningBalance" statement in the Credit field code panel. There can not be any hidden procedures, formulas or code snippets in the database. Still, the behavior is the same.

If I run the procedure “Recalculate RunningBalance” from the Action menu, it acts on the RunningBalance, as expected and desired. However, if the statement call "Recalculate RunningBalance" is run through a field code panel, the procedure acts on the Balance field.


Thanks again Gary, but unfortunately no progress. I’m still experiencing the same behavior even with your code suggestion of

field RunningBalance
field Balance
formulafill Credit-Debit

In my case, I want the Balance field to contain a constant value that I enter, and the RunningBalance field to be a calculated field. Right now, when coming out of a field containing call "Recalculate RunningBalance" the code is running on the Balance field rather than on the RunningBalance field.


To be sure we are on the same page, here is a screenshot of the Properties panel for the Code in both the Debit and Credit fields:

I created a procedure with the code you gave for the Recalculate RunningBalance procedure and then made a little gif movie of how it is working for me.

Unless you have some other code affecting things I have no idea why you are having different results than me.


Well, it looks like we may have stumbled onto a bug. I had been leaving the Debit or Credit field with the Enter key while I’m sure you are using the Tab key. Evidently the tab is being executed in the called procedure right before the formulafill statement - not good! Here is a workaround that will get the proper field filled. Replace your "Recalculate RunningBalance" procedure code with this:

field RunningBalance
If info("fieldname")="Balance"
    field RunningBalance
formulafill Credit-Debit


Thank you very much, Gary. You have gone above and beyond.

Yes, you are correct. I have been using the Tab key. Your procedure code has corrected the behavior and my RunningBalance field is getting updated correctly now.

Thank you again for clearing that up. It had me stumped.


I’d be interested in seeing this pursued: I have a number of situations in which I have to remember to exit a field with the enter key because the tab key produces unexpected results. No time right now for detailed report, but it does seem like there’s a problem here.


This has been discussed in the forum before. You cannot change the current field in the automatic code that runs after the tab key is pressed. When you do that, you are giving Panorama conflicting commands about where the current field should go – the code says one thing, but the tab key says another. It turns out the tab key overrides the code, so your code doesn’t work. This is not going to change, however, Panorama 10.1 does provide a way to change the tab order on the fly.

Personally I think using formulafill and runningtotal in code triggered by data entry is a bad idea. It’s certainly going to have performance issue if the database is large. But if you really want to do this, I would suggest using the starttimer statement to delay the code for 0 seconds, that way it will run after the tab handling is finished.