class dlsalesDATAMODULE of DATAMODULE this.SALES = new ADOQUERY(this) with (this.SALES) left = 2.0 top = 2.0 database = mcompany.adodb sql = 'Select sales.* , sales.qty* sales.rate - sales.misc as amount, if(sales.mast<0,100,10) as order_col from sales19 sales WHERE ddate = :dldate AND locat = :locat AND mast <>0 ORDER BY invoice_no ,order_col' params["dldate"].value=dtos(date()) params["locat"].value="0" requestlive = false active = true endwith The above portion is code from Datamodule. And below is the code from the form where the datamodule is being used. If is part of Refresh Data button onClick event form.dlsalesdatamodule1.sales.params["dldate"].value = dtos(form.dl_date.value) form.mdl_date = form.dl_date.value do case case lower(form.location.value) = "head office" form.dlsalesdatamodule1.sales.params["locat"].value= "0" form.mdl_locat = "0" case form.location.value = alltrim(mcompany.go1) form.dlsalesdatamodule1.sales.params["locat"].value= "1" form.mdl_locat = "1" case form.location.value = alltrim(mcompany.go2) form.dlsalesdatamodule1.sales.params["locat"].value= "2" form.mdl_locat = "2" endcase form.dlsalesdatamodule1.sales.requery()