Return the cursor to the current field after a procedure runs

Greetings. I am in way over my head with Panorama X, using advanced functions on my 9th day of using it. I’ve created a transaction table for brokerage data input with the fields always being positive, e.g. a sell order is still entered as a positive number for shares even though shares will decrease. The buy dollar amount is entered as a positive, even thought the cash is going out and the balance will decrease. So I have code to change what’s input (like sh_input) to what the actual field is (shares) and change to a positive or negative as required.

I have a Balance field that is updated for almost any change to the Transaction record. After my code runs, the cursor ends up on the Balance field-not unexpectedly. Is there a way to redirect the cursor to the field that was changed, or the next field in the tab order?

(Yeah, crazy to do something this complex as a newbie…I know that. I’m racing against a deadline so that I don’t have to renew my Quicken subscription next month).

Most of the fields that would affect Balance call the procedure below:

if Action = "Buy"
  Basis = Amount + Fees
  Cash = (Amount + Fees) * -1
  Shares = Sh_Input
Elseif Action = "Sell" 
  Basis = Basis_Input*-1
  Cash = Amount - Fees
  Shares = Sh_Input*-1
Elseif Action = "Xfer"
  Basis = Basis_Input*-1
  Cash = 0
  Shares = Sh_Input*-1
Elseif Action = "Adj"
  Basis = 0
  Cash = Amount
Elseif Action = "Cash"
  Basis = 0
  Cash = Amount
endif

Field Balance
formulafill 0+Cash
runningtotal

Thanks for any help you can provide.

You need to store the name of the current field in a variable before you move to another field, so that you can return to it when you are done. You can put

let thisField = info("fieldname")

at the beginning of your procedure and then put

field (thisField)

at the end. Be sure to include the parentheses in that last statement. It’s a quirk of the field command. Without them Panorama will be looking for a field whose actual name is thisField.

1 Like

Wow, thanks, Dave. That worked great!

Coming from an SQL and spreadsheet background, I am amazed that a running total is so easy to generate.

1 Like