# Formname of form within another form

**URL:** <https://forum.servoy.com/t/formname-of-form-within-another-form/17023>\
**Category:** Classic Servoy\
**Created:** [February 15, 2013, 5:35am UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023 "2013-02-15T05:35:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylockson](https://avatars.discourse-cdn.com/v4/letter/y/b487fb/32.png) [@ylockson](https://forum.servoy.com/u/ylockson)\
**Post date:** [February 15, 2013, 5:35am UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023/1 "2013-02-15T05:35:10Z")

</div>

In a form that contains other forms, can one programatically get the formname of the ‘active’ form (i.e. where the cursor previously was) from within a button that is located in the header part of the parent form?

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [February 15, 2013, 7:49am UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023/2 "2013-02-15T07:49:42Z")

</div>

to get the parentForm of a nested (tabpanel) form:

```auto
var vDataset = controller.getFormContext();
	if (vDataset.getMaxRowIndex() > 1) {
		var vParentFormName = vDataset.getValue(vDataset.getMaxRowIndex() - 1, 2 )
        }

```

you can get more information out of that vDataset, if you want…

---

<div class="post-metadata">

**Author:** ![ylockson](https://avatars.discourse-cdn.com/v4/letter/y/b487fb/32.png) [@ylockson](https://forum.servoy.com/u/ylockson)\
**Post date:** [February 15, 2013, 5:53pm UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023/3 "2013-02-15T17:53:06Z")

</div>

Harjo,

My initial post was probably not clear enough. Apologies…

I wish to be able to navigate through records of any form (parent) and its sub-forms (children) using buttons placed in the header part of the parent form. I understand that the problem is context. As soon as I click on any button located in the header part, context returns to the parent form. I had hoped that Servoy would have a function/method that could be used to work around this.

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)\
**Post date:** [February 15, 2013, 6:18pm UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023/4 "2013-02-15T18:18:50Z")

</div>

> ylockson:  
> I wish to be able to navigate through records of any form (parent) and its sub-forms (children) using buttons placed in the header part of the parent form. I understand that the problem is context. As soon as I click on any button located in the header part, context returns to the parent form. I had hoped that Servoy would have a function/method that could be used to work around this.

When you enter a child form (form \> onElementFocusGained probably), set a form variable on the parent form with some sort of context string or object. Then set the code in your nav buttons to refer to this form variable for what to navigate.

---

<div class="post-metadata">

**Author:** ![ylockson](https://avatars.discourse-cdn.com/v4/letter/y/b487fb/32.png) [@ylockson](https://forum.servoy.com/u/ylockson)\
**Post date:** [February 17, 2013, 3:08am UTC](https://forum.servoy.com/t/formname-of-form-within-another-form/17023/5 "2013-02-17T03:08:03Z")

</div>

David,

Good suggestion. However, for the navigation buttons to also work correctly for the outermost form, the same onElementFocusGained method of the inner forms must also be set for the outermost form but must not ‘react’ to any navigation button. Otherwise, context will be lost again.

Thanks. I’ll try that.

ps. I wonder whether the incessant activation onElementFocusGained event is ‘expensive’ especially in cloud computing. The best solution would be for Servoy to supply a special button type or property that does not shift context.
