I have a tab panel that shows another tab panel, which displays a form. As I change data on the form (move to a new record in the found set), I notice that the tab panels do not “refresh” and show the changed data.
I find myself calling the “relookup” function for the relationship from the tab to the subform, to refresh the data.
Spoke too soon. Application.updateUI() is not working for me.
Here are some more details:
the contact form is related to an address table.
I have retrieved the foundset of addresses for this contact using an SQL query (4 addresses in the table)
the contact form displays the first address in the found set no problem.
I have four buttons on the contact form, one for each address.
When the user clicks on btn 2, I select the second record in the address table, but the form still shows the first address. I need it to refresh with address 2.
I am using this code to refresh the form (which is not working):
To be honest, what appears to be happening, is it is showing field valuesn in the form from the prior selection. For example, click btn 2, nothing changes (still shows values from address 1). Click btn 3, and it now shows values from address 2. Etc.
I am definetly selecting the right record in the address table when the button is clicked.
This is really very simple, so I am confused as to why this is not working.
Out of my head: I think selectRecord() takes the primary key of the record, not the index in the foundset. Use setSelectedIndex() instead and it should work.
Just for debugging purposes, you could add a tabpanel to your form, showing the foundset of adresses in a Tableview. Then you can see which record actually gets selected.
Secondly, if those adresses have a type column of some sort, you might have a look at using a global relation with, besides the keys to relate an address to a contact, also an extra key with a global containing the type you want on the left and on the right side the field that indicates the type.
BTW: what is the reason to use SQL to get the related adresses? Can;t you get to them over a relation from Contacts to Adresses?
I have already added a tabpanel showing the address table on the contact form and can see that I am selecting the correct record in the address table (I have tried to use both setSelectedIndex and selectRecord, and have both approaches working; selecting the right address, but this does not solve the problem).
Let me try explaining again what is going on.
tab_Contacts (tab panel with four buttons; frm_contacts relationless form used)
frm_Contacts (form that shows the details, shows field details from relationship to tbl_addresses)
tbl_addresses (all related addresses for the current contact)
When I click btn 2 on tab_contacts, frm_contacts shows the correct data for address 2 and tbl_addresses shows that address 2 has been selected. tab_contacts, however, does not show the correct data; it shows the prior selected addresses data. For example, when I click on btn 3 on tab_contacts, frm_contacts and tbl_addresses are again correct, but tab_contacts shows now the data from address 2 (previously selected).
Definitely a refresh issue, and I can not figure it out.
BTW, I made a mistake about using SQL to get the related addresses (must have been thinking of my SQL filtering I was doing earlier). I am using a simple relation contacts to addresses by contact ID, and that works fine.
So you have 2 tab panels what are they exactly showing?
one a related foundset as a tableview?
and one the normal parent foundset with related fields of that same foundset you have in that other tab panel?
That won’t work. a related field on a form will not follow the selected index of the foundset constantly. It will show you the value when the record is set (when you show the form or set the selected index)
When you want 2 tab panels to be in sync. so 1 shows the tableview and one shows the details, then make sure that both are using the exact same foundset. So both tab panels should be build on the same table. Then they will follow each other.
If you really want to follow this setup:
parent form with related data
child form with related data in tableview
and the parent form HAS to follow the tableview then there is i think one workaround. The child forms onRecordSelection, should quickly change the parents form selected index and back… You have to ignore then the onRecordSelection that wll be triggered by that index setting you do yourself…