Reducing the foundset in a tabpannel from your mainform

Hi,

I’m trying to make a checkbox on my mainform that reduces the foundset on one of the tabpanels that is showing. I have a global field, of type “checkbox” and attached to that I have a OnDataChange method with the following code:

if ( globals.ShowAll2 )
{
forms.invoices_for_match_right.controller.loadAllRecords()
}
else

{
forms.invoices_for_match_right.controller.find();
forms.invoices_for_match_right.status = ‘Open’;
forms.invoices_for_match_right.controller.search(true,true)
forms.invoices_for_match_right.controller.loadRecords();
}

But it doesn’t. I get the message: “Search failed…try show all”

It leaves me clueless…

Another thing: after I clicked away the erormessage, the field on my tabpanel become editable again…

if you attach a checkbox to your field (without valuelist) it will enter 1 if checked, and 0 if unchecked, so it’s better to do this:

if ( globals.ShowAll2==1 )
{

One other thing:
If you want to fill your tabpanel with all related records again, you should
use

forms.invoices_for_match_right.controller.loadRecords()
instead of…

forms.invoices_for_match_right.controller.loadAllRecords()

laodAllRecords will override the relation of the tabpanel,
and simply show all table records in your tabPanel.

Maarten, tnx

I fiddled around with your comments a bit. I got it working in the end, by commenting out the last line of code. With the line not commented out I get an errormessage very time:

“Error setting Formmodel, Can’t set a model from table customers for form table invoices”

Can you tell me what is means?

And also, I thought I always had to do a loadRecords after a find/search combination… I guess i was wrong

There is a typo in the error msg, it should say:
Can’t set a foundset from table customers into a form using table invoices
I think this makes it clear.

Jan, Maarten,

When I do a plain and simple find in a form, no relationship or wahtsoever, I see no difference in behaviour concluding it with a control.loadRecords() or control.loadAllRecords().

is this correct?

see manual, clearly explained :-)

sorry :oops: :oops: :oops: