NetTalk Central

Author Topic: updating fields on another tab when tab changing  (Read 3893 times)

robirenz

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
updating fields on another tab when tab changing
« on: December 14, 2011, 07:41:53 AM »
Hi Bruce..
I have a form with using the "Tab" style
I have my main data on the first tab
and tables on each added tab
If I go to tab2 which has a table.
If I add a record on that tab..
I want to add up whatever records I added to that table
My Total field in tab one that is made up of serveral sumatories needs to be updated
I have a routine that does the adding up, so all I need to do is run my routine to add the stuff up but I can't seem to be able to run my routine when I do the tab changing.
I have only been able to update the total field using my routine with a button or something like that.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: updating fields on another tab when tab changing
« Reply #1 on: December 14, 2011, 11:07:18 PM »
In build 6.10 (and later)
There is a routine in the Form called TabChanged
This is called when the user changes a tab using the Accordion, Tab or Wizard tab styles.

In this routine a local variable called TabNumber is set. Please note that tabs are zero-based, so the first tab is tab 0.

There are embed points in this routine where you can add code to "refresh" other items on the screen. For example;

do FormHeading ! refreshes the heading on the form
do Refresh::fieldname  ! refreshes the specific field on the form


and so on.

One common request when a tab changes is to change the Heading (or sub-heading) on the form. To make this easy to do an array variable called TabHeading is generated into the routine as well. This is populated with the tab headings.

HOWEVER NOTE THAT : Arrays in Clarion are '1' based, and the TabNumber is 0 based, so to set the heading you will need something like;

myFormHeading = TabHeading[TabNumber+1]
do FormHeading


and of course myFormHeading is a local variable you've defined, and you've set either the heading or subheading to myFormHeading.

cheers
Bruce