Pb with report

Hi, Vince. Yes, it’s exactly how it should work looking at the code. If you want to add Ranges to other datasources - children of Vue_Clients_light - than you have to add them in the init method. But it’s harder to do, because you have to look out for all the relations and ranges. But, of course, possible. What you need to do is very much like what you are doing with the ranges right now. But I am not sure it will work the way it should. You will have to try it out, and work on it some more to set things right. public void init() { Args args = element.args(); Query qVue_Clients_Light = new Query(); Query q2 = new Query(); int i,j=0; ; qVue_Clients_Light = args.caller().parmQuery(); q2.addDataSource(tableNum(country)); info(q2.datasourceNo(1).toString()); info(qVue_Clients_Light.dataSourceNo(1).toString()); for (i = 1; i <= qVue_Clients_Light.DataSourceCount(); i++) { q2.dataSourceNo(i).addDataSource(qVue_Clients_Light.DataSourceNo(i).table()).relations(true); for (j = 1; j <= qVue_Clients_Light.DataSourceNo(i).rangeCount(); j++) { box::info(qVue_Clients_Light.DataSourceNo(i).range(j).name() + " = " + qVue_Clients_Light.DataSourceNo(i).range(j).value()); q2.dataSourceNo(i+1).addRange(qVue_Clients_Light.DataSourceNo(i).range(j).field()).value(qVue_Clients_Light.DataSourceNo(i).range(j).value()); } } info(q2.datasourceNo(1).toString()); this.query(q2); }

Ok, so I have used your code and now in my report I have 2 datasources “County” (the standard source) and “Vue_Clients_Light” ( the datasource of the grid). public void init() { Args args = element.args(); Query qVue_Clients_Light = new Query(); int i,j=0; ; if(flagOneTime == false) { qVue_Clients_Light = args.caller().parmQuery(); for (i = 1; i <= qVue_Clients_Light.dataSourceNo(1).rangeCount(); i++) { this.query().dataSourceNo(2).addRange(qVue_Clients_Light.dataSourceNo(1).range(i).field()).value(qVue_Clients_Light.dataSourceNo(1).range(i).value()); } for (i = 2; i <= qVue_Clients_Light.DataSourceCount(); i++) { this.query().dataSourceNo(i).addDataSource(qVue_Clients_Light.DataSourceNo(i).table()).relations(true); for (j = 1; j <= qVue_Clients_Light.DataSourceNo(i).rangeCount(); j++) { this.query().dataSourceNo(i+1).addRange(qVue_Clients_Light.DataSourceNo(i).range(j).field()). value(qVue_Clients_Light.DataSourceNo(i).range(j).value()); } } flagOneTime = true; } BUT, like everytime there is a “but”… You know I would like the report looks like this(for the body): County | Number of Clients 01 | 12 02 | 23 03 | 0 04 | 10 05 | 0 06 | 0 07 | 13 08 | 0 The problem is that the body only have one datasource, so if I put “County” as datasource of the Body, I don’t know how to use the records from Vue_Clients_Light_1 (the datasource of the report). You know, You can’t do something like: while select * from Vue_Clients_Light_1 {} To see the records of Vue_Clients_Ligth_1 (report datasource) It has to be in a body with Vue_Clients_Light_1 as datasource and then it 's possible to do: Vue_Clients_Light clients; while select * from clients where clients.accountnum == Vue_Clients_Light_1.accountnum {}

Hi, Vince. I didn’t quite understand what the problem is right now. But I think I found the solution to it anyway. :slight_smile: I accidently stumbled upon this method in the Global class static void queryMergeRanges( Query q, Query initQ, Int initQdsNo = 1, boolean alwaysAddDatasource = false, boolean addSameFieldRange = true ) { ; sysQuery::mergeRanges(q,initQ,initQdsNo,alwaysAddDatasource,addSameFieldRange); } I have never used it before, but considering from the name and the amount of code in SysQuery::mergeRanges() I think it does exactly what you need. So you can add all the datasources you need to the report, and than in the init() just call this method. I will research on how it works today too. Hope it helps. Vanya

Sorry, Vince. Just re-read your topic. I guess you’ve already done the query. So the query is ok. all ranges are set, etc. Right? And what you are asking about now is the report itself? Or what?

My explanation wasn’t very good, sorry… Yes all is ok, but… In the report, I have 2 datasources : County and Vue_Clients_Light. The second one is now the same as the datasource of the grid when the user clicks on the button to make the report.So it’s good. Now it’s just a problem of manipulation of data in the report. I think I have to put “County” as datasource of the body and then, for each county, I have to count how many clients (coming from the datasource Vue_Clients_Light_1 of the report) there are in each county. But I don’t know how to get the records of the datasource Vue_Clients_Light_1 if the datasource of the body is not Vue_Clients_light… Vince

Well, apart from specifying the datasource for the entire body (the Table property) you can do the same with each field in the body. (Table property and DataField or DataMethod depending on what you need). you can specify any table and field for any control in the report