When do formulas and code run

When does a formula in a field run?
When does the code in a field run?
If there is both a formula and code in a field when do they run and which runs first?

See help entries under Automatic Field Calculations and Automatic Field Code respectively.

Panorama runs the formula calcualtions first, then the code (if any).