Use of query elements in report using axapta


 public boolean fetch()  
 {  
 QueryRun qr;  
 QueryBuildRange rangeTransDate;  
 Boolean ret;  
 qr = new QueryRun(element);  
 rangeTransDate =  
 element.query().dataSourceTable(tablenum(CustTrans)).addRange(fieldnum(CustTrans, transDate));  
 rangeTransDate.value(queryRange(systemdateGet()-daysBack, systemDateGet()));  
 rangeTransDate.status(RangeStatus::LOCKED);  
 element.design().caption(strfmt("%1, %2", element.design().caption(), rangeTransDate.value()));  
 if (qr.prompt() && element.prompt())  
 {  
 while (qr.next())  
 {  
 custTable = qr.get(tableNum(CustTable));  
 custTrans = qr.get(tableNum(CustTrans));  
 if (!custTable)  
 {  
 ret = false;  
 break;  
 }  
 if (qr.changed(tableNum(custTable)))  
 {  
 element.send(custTable, 1);  
 }  
 if (qr.changed(tableNum(custTrans)))  
 {  
 element.send(custTrans, 2);  
 }  
 }  
 ret = true;  
 }  
 else  
 ret = false;  
 return ret;  
 }