Several tableboxes in one form with different parameter

hai there
i want to view some tableboxes(from the same table) in one form
SourceTable for this form , let’s say → Status (table Status)

i want to use tabcontrol with 2 tabs
in tab 1 , table box will show table status that status_id = 1
and in tab 2, table box will show table status that status_id = 2

how can I do that?
thanx for the help :slight_smile:

You need to create a subform and you can put the subform on the 2 tabs with different filters.

wow … it’s working

thanks Kriki…

but if the parameter is Entry Date → yesterday and today

how can i do that?

There are 2 ways (the code for both solutions must be put in the “OnAfterGetCurrentRecord”-trigger of the mainform [or better : create a function with the code in and that function you can call from all places you need]):

  1. (Never tried this but I just noticed that on the subform can use a SETTABLEVIEW) create a global in the mainform of type record of the table in your subform. Put on it all the filters you need (put them in another FILTERGROUP) and then put them on your subform. Some code like this:

TheTable.RESET;

TheTable.SETCURRENTKEY(…);

TheTable.SETRANGE("…",…);

TheTable.SETRANGE(“Entry Date”,TODAY);

CurrForm.Subform1.FORM.SETTABLEVIEW(theTable);

CurrForm.Subform1.UPDATE(FALSE);

TheTable.SETRANGE(“Entry Date”,TODAY - 1);

CurrForm.Subform2.FORM.SETTABLEVIEW(theTable);

CurrForm.Subform2.UPDATE(FALSE);

  1. Create a function in your subform that receives the date and puts the filter on “rec” and does a CURRFORM.UPDATE(FALSE); From the mainform you call the function in both subforms.

my code :

//For Today

WO.RESET;
WO.FILTERGROUP(2);
WO.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO.SETFILTER(“Status Date”,’=%1’,TODAY);
CurrForm.SchedulesToday.FORM.SETTABLEVIEW(WO);
WO.FILTERGROUP(0);

//for Another day

WO2.RESET;
WO2.FILTERGROUP(2);
WO2.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO2.SETFILTER(“Status Date”,’=%1’,TODAY);
CurrForm.SchedulesToday1.FORM.SETTABLEVIEW(WO2);
WO2.FILTERGROUP(0);

I use 2 subforms

but in the second subform, it always take last record in subform 1

i must refresh the form , before get the right information

why this could happened?

Try a CurrForm.UPDATE at the end of your code.

And you use TODAY in both parts of you code…

sorry, i mean like this

//for another day

WO.RESET;
WO.FILTERGROUP(2);
WO.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO.SETFILTER(“Status Date”,’=%1’,TODAY);
CurrForm.SchedulesBeforeToday.FORM.SETTABLEVIEW(WO);
WO.FILTERGROUP(0);

I already add code currform.update at the end

but it still the same

I must refresh it before it show the right information

Last record in WO(table for subform scheduletoday) will be shown in the WO2 (table for subform schedulebeforetoday)

I have another way

in the subform I made it to be load in the trigger onTimer → like auto refresh

it would be refresh every several seconds

is it a good idea to solve this problem?

Some changes:

//For Today

WO.RESET;
WO.FILTERGROUP(10); // filtergroups 1 to 6 are reserved, so best leave some others for the future
WO.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO.SETRANGE(“Status Date”,TODAY); // if possible, use SETRANGE and not SETFILTER.
CurrForm.SchedulesToday.FORM.SETTABLEVIEW(WO);
WO.FILTERGROUP(0);

//for Another day

WO2.RESET;
WO2.FILTERGROUP(10);
WO2.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO2.SETRANGE(“Status Date”,TODAY - 1); // TODAY - 1 for yesterday
CurrForm.SchedulesToday1.FORM.SETTABLEVIEW(WO2);
WO2.FILTERGROUP(0);

CurrForm.UPDATE(FALSE); // to update all

It is normal you have to refresh, you just changed filters and send them into the subforms, but they will not refresh until you say so (or until you do certain actions on the form).

Still wrong

My Data (Full Without Filter)

Workorder Register Status Location Status Date
1 Workorder 14/02/2008
2 Inhouse 19/02/2008
3 Vendor 16/02/2008
4 Inhouse 04/02/2008
5 Inhouse 01/01/2007
6 Workorder 19/02/2008
7 Workorder 19/02/2008
8 Workorder 15/02/2008
9 Inhouse 19/02/2008

Sub form 1 → ScheduleToday

it should be just show where Status location = workorder

and status date = 19/02/2008 (TODAY) → workorder register 6 & 7

Sub form 2 → ScheduleBeforeToday

it should be just show where Status location = workorder

and status date = 19/02/2008 (Not TODAY) → workorder register 1 & 8

but in your code

sub form 1 → workorder register 7 , 6 , 5

sub form 2 → workorder register 5

my main problem is just a record from sub form 1 is added to subform 2

so i must refresh it first (CTRL + ALT + F5)

I just want to know how to be without refresh it

This is for the filters

//For Today

WO.RESET;
WO.FILTERGROUP(10); // filtergroups 1 to 6 are reserved, so best leave some others for the future
WO.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO.SETRANGE(“Status Date”,TODAY);
CurrForm.SchedulesToday.FORM.SETTABLEVIEW(WO);
WO.FILTERGROUP(0);

//for Another day

WO2.RESET;
WO2.FILTERGROUP(10);
WO2.SETRANGE(“Status Location”,“Status Location”::Workorder);
WO2.SETRANGE(“Status Date”,0D,TODAY - 1); // now it takes all dates BEFORE today
CurrForm.SchedulesToday1.FORM.SETTABLEVIEW(WO2);
WO2.FILTERGROUP(0);

CurrForm.UPDATE(FALSE); // to update all

To refresh automatically your subforms, you can put (on the subform) form-property TimerInterval=1000 to trigger every second.

In the Form - OnTimer()-trigger, you can put

CurrForm.UPDATE(FALSE);

There is a negative on this: you can only use this if you are NOT editing in the form because it can be updated while you are editing a record. In this case, the only way is the manual refresh.

I change my mind
I change data type for “status Date” from Date to DateTime
but I cannot change SETRANGE for today → WO.SETRANGE(“Status Date”,TODAY);
in the field ==> 010108 12:00:00, 010108 17:12:23, 010108 23:12:11
how can i setrange field tor day 010108 ??

SETRANGE(“Status Date”,CREATEDATETIME(DMY2DATE(1,1,2008),0T),CREATEDATETIME(DMY2DATE(1,1,2008),235959T));

This statements looks almost a LISP-statement (LISP=a Lot of Irritating Strings of Parenthesis). [A]