# Running code when the user leaves a tab of a sheet

**URL:** <https://forums.softvelocity.com/t/running-code-when-the-user-leaves-a-tab-of-a-sheet/2154>\
**Category:** Knowledge Base\
**Tags:** templates, unverified\
**Created:** [November 12, 2026, 2:29pm UTC](https://forums.softvelocity.com/t/running-code-when-the-user-leaves-a-tab-of-a-sheet/2154 "2026-11-12T14:29:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzaunere](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rzaunere](https://forums.softvelocity.com/u/rzaunere)\
**Post date:** [November 12, 2026, 2:29pm UTC](https://forums.softvelocity.com/t/running-code-when-the-user-leaves-a-tab-of-a-sheet/2154/1 "2026-11-12T14:29:03Z")

</div>

**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.
