Jump to content
Sign in to follow this  
michael_w

Script switches to different tab - why?

Recommended Posts

Hi - I'm using FMP8 and have some trouble with my DB.

I have a layout with multiple tabs - say tabs A, B, C, D. Each tab has a portal. The tab showing is C and it has a button to execute a script. As soon as the script hits the Go to Portal Row step FMP switches to a different tab.

I tried creating a field, made it visible only on tab C, and then added a Go to Field step before the Go to Portal Row, but it still changes the tab.

Why? And how can I make FMP stay on the same tab?

Here's my script:


Set Field [ t.AccountsUI::g.CurrentTab; "Transactions" ] 

Go to Layout [ original layout ] 

Go to Field [ t.AccountsUI::k.Transactions ] 

[ Select/perform ] 

Set Field [ t.AccountsUI::k.Transactions; "Transactions" ] 

Set Selection [ t.AccountsUI::k.Transactions ] 

Go to Portal Row [ 1 ] 

[ Select ] 

Edited by Guest
added code snippet

Share this post


Link to post
Share on other sites

There are two potential causes for this:

1. You have the same field on the layout in two different tabs. The frontmost field in the layout's stacking order is where it's going to go, and if that field is in the portal any "Go to Portal Row" step is going to go to the portal where that field resides. If you have FMPA, turn on the debugger and step through it to see why.

2. If you have more than one portal on a layout, you must first go to a field inside of the portal you wish to go to or it will choose the topmost portal in the layout's stacking order.

NB, if you had FMP 8.5 or higher, you could explicitly name these objects and go to them by name. Then you wouldn't be dependent on first going to a particular field within the portal.

Share this post


Link to post
Share on other sites

Thanks David.

I have the following (as this DB is work in progress some tabs are empty):

  • tab Files - empty
  • tab Groups - empty
  • tab Accounts - portal to table t.Accounts and some global fields from local table t.AccountsUI
  • tab Units - portal to table t.Units and some global fields from local table t.AccountsUI
  • tab Overview - portal to table t.Transactions and some global fields from local table t.AccountsUI plus a few fields from table t.Accounts and t.History
  • tab Transactions - portal to table t.Transactions and some global fields from local table t.AccountsUI plus some fields from table t.Transactions (not in portal) like the field k.Trasnactions that I put only onto this tab in the hope it would keep the focus on this tab
  • tab Parties - portal to table t.Parties and some global fields from local table t.AccountsUI
  • tab Regulars - empty

The script I'm running is activated by a button on the tab Transactions. When it hits the Go to Row 1 step it jumps to the first row on the portal of tab Accounts.

I tried by changing the script and added a Go to Field step pointing to a field in the t.Transactions table on the portal of the tab Transactions, but when it executed this script step it jumped to that field on the tab Overview as this also has a portal to the table t.Transactions.

Looks like I'm caught by the short and curlies and will have to upgrade...

Share this post


Link to post
Share on other sites

As far as I know FMP will use the fields on the layout in the sequence they appeared there, so you could just remove and replace the offending field - then it will be the last field on the layout, so your go to field instruction will then use the other instance.

What about the field set up - remove access in find mode?

Don't forget the TAB sequence too.

Share this post


Link to post
Share on other sites

Hi IdealData - are you talking about the same thing? Your explanation seems more applicable to navigating from one field to another using the tab key, but I was referring to tabbed portals.

Share this post


Link to post
Share on other sites

IIRC, prior to Go to Object, you needed a unique field (different TO's okay) on each tab for the Go to Field trick to work. Since two of your portals are using the same field from the same table occurrence, this will not work.

You can try creating a global field for each tab that you want to go to and use that, or you can use one repeating global field and put a different repetition on each tab. Then you can use Go to Field, referencing the repetition of the field.

OR...

You can just upgrade. :

Share this post


Link to post
Share on other sites

prior to Go to Object, you needed a unique field (different TO's okay) on each tab for the Go to Field trick to work. Since two of your portals are using the same field from the same table occurrence, this will not work.

It still might.

SelectPortal.fp7.zip

Share this post


Link to post
Share on other sites

Hi John - I'm already doing that. The field k.Transactions is unique to the Transactions tab where I want to remain. I can see the script selecting that field but the subsequent Go to Row step makes it jump to the Overview tab again.

I also tried it with a repeating field - no change :

Share this post


Link to post
Share on other sites

... I keep playing with it and even though I'm still doing what I've done so far, i.e. Go to Field followed by Go to Row 1 it now jumps to the 1st row of tab Accounts which doesn't share the same portal. Before it was jumping to the tab Overview which at least hared the same portal to the table t.Transactions with the Transactions tab, but now?:

Share this post


Link to post
Share on other sites

Sorry comment - I had overlooked your attachment. Yes, I tried it and it does select the right tab when I press the buttons - cool :

I need to study your solution a bit more before I understand how it works.

Share this post


Link to post
Share on other sites

Sussed it - excellent comment, thanks for your help :smile2:

My problem was that I hand't put the unique field into the first portal row. Instead I had placed it just on the tab outside the portal.

Many thanks to everyone contributing - it's good to know that one isn't alone...

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.