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
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]):
(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);
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.
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);
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).
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 ??