Running code when the user leaves a tab of a sheet

Applies to: posted in comp.lang.clarion in 2020; the thread does not name a Clarion version or template chain.

Problem

A form had several tabs on a sheet. On the first tab the user sets a filter. When the user selects another tab, the poster wanted some code to run. He thought of the sheet's TabChanging embed but did not know how to use it.

Solution

  1. Open the Embeds of the sheet and use Event:TabChanging. In it CHOICE(?Sheet) is the tab being left (here tab 1).
  2. Alternative: the sheet's NewSelection embed (after the generated code), with CASE CHOICE(?Sheet:Reports) and an OF arm per tab number. By then focus is already on the new tab.
  3. Instead of the tab number, ?Sheet{PROP:ChoiceFEQ} returns the tab's ?Tab:Name FEQ, so the code survives a change of tab order, for example a new tab inserted as tab 1.
  4. The poster reported TabChanging was the best choice, as it works on leaving the tab.

Caveats

  • ?Sheet is not likely to be your own FEQ; use the label your sheet has.
  • CHOICE() returns the tab index (1, 2, 3 ...), so hard-coded numbers break when tabs are reordered.
  • The thread gives no code for the TabChanging embed itself.

Today (2026)

Likely still valid on current Clarion, not re-tested.

Sources: Koen T. (Jul 2020, the question), Bob C., Carl (Jul 2020) in comp.lang.clarion.