onRecordSelection gives unexpected result

Hi All

I am using an onRecordSelection to load an unrelated foundset into a table view in a tabpanel on my form. This works fine when I scroll through records, or perform a search on the parent form. It doesn’t work though (loads the wrong foundset into the tabpanel) if I arrive at this form using another form’s method to get there eg. showRecords (foundset). The other method doesn’t touch the related child records in my tabpanel, and doesn’t load anything else…

Any ideas on how to always load the right foundset when I get to a record, whichever method I used to get there? onShow would only fire when the form shows, so I couldn’t use it to trigger the method when advancing through records, and onLoad would trigger when a new foundset is loaded to the form, but again not when advancing through records, right? What else is there?

Thanks

Bevil.

Hi Bevil,

onRecordSelection is triggered whenever a different record is selected. So it sounds kind of strange that it doesn’t get fired.
What could be the situation is: it get’s fired but you’re still in the wrong scope to get the result you’d like.

What you could try is call the ‘onRecordSelection’ method from the ‘onShow’ method.
If I’m not mistaken the ‘onShow’ has a default argument which tells you whether the form is ‘first time showed’ or not.
You could use this argument to determine if you should call the onRecordSelection or not (I’d think ‘first time show’ does always trigger the onRecordSelection so you don’t want it to be triggered twice…)

Hope this helps.

Hi Marc

Yeah, I’m surprised by the result and can only assume that something else is going on (although there is no onLoad, onShow or onRecordSelection on the child form, so I don’t know what it might be…)

Are you saying I should have an onRecordSelction AND an onShow?

Thanks

Bevil

Thunder:
Are you saying I should have an onRecordSelction AND an onShow?

Just create an ‘onShow’ method that calls the ‘onRecordSelection’ method.
So leave the onRecordSelection as it is, because this works in 99% of the time.
Just when the form is showed it will trigger the ‘onShow’ which will trigger the ‘onRecordSelection’…

Hi Bevil

The onRecordSelection can also get triggered by statements (methods) in your code, for example if you use .setSelectedIndex(i) the onRecordSelection is triggered. The easiest way I found when you have the suspicion the foundset is not the expected one, I look at it in the Interactive Console (Tab) in the debugger entering for example foundset.alldataproviders and then the individual dataproviders.

Regards, Robert