# Button bar active segment by calculation

**URL:** <https://the.fmsoup.org/t/button-bar-active-segment-by-calculation/3367>\
**Category:** Questions\
**Tags:** button-bar\
**Created:** [February 7, 2023, 11:06pm UTC](https://the.fmsoup.org/t/button-bar-active-segment-by-calculation/3367 "2023-02-07T23:06:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [February 8, 2023, 1:48am UTC](https://the.fmsoup.org/t/button-bar-active-segment-by-calculation/3367/4 "2023-02-08T01:48:29Z")

</div>

In a simple test file this code works.

```auto
Set Variable [$$activeSegment ; "NavBtnBar_Invoice"]
Refresh Object ["NavBtnBar"]

```

1. Buttonbar is named "NavBtnBar". It has three segments, labelled "Invoice", "Customer","Product"
2. The button segments are named (object name not button label) "NavBtnBar\_Invoice", "NavBtnBar\_Customer", "NavBtnBar\_Product"
3. Active segment calculation is "$$activeSegment"
4. create a script using the script steps above.

To see the active button segment being changed, select any segment except "invoice" then run the script. If you have set everything up correctly the "invoice" segment is displayed in the active state.

Edit:

1. if the calculation uses a field in the current record, and that field is modified, that would trigger an immediate update.
2. the calculation can use a field in a related record, and that will trigger an update
3. rearrange the steps above for easier understanding

---

_[View the full topic](https://the.fmsoup.org/t/button-bar-active-segment-by-calculation/3367)._
