LOCAL add_if monthfm=thisform.monthfm.value monthto=thisform.monthto.value If !thisform.cfname.value=1 add_if = "code>=thisform.codefm.value and code<=thisform.codeto.value and sec>=thisform.secfm.value and sec<=thisform.secto.value and scode>=thisform.shiftfm.value and scode<=thisform.shiftto.value and lcode>=thisform.levelfm.value and lcode<=thisform.levelto.value and admtd=1 and !dr-cr=0" ELSE add_if = "code>=thisform.codefm.value and code<=thisform.codeto.value and sec>=thisform.secfm.value and sec<=thisform.secto.value and scode>=thisform.shiftfm.value and scode<=thisform.shiftto.value and lcode>=thisform.levelfm.value and lcode<=thisform.levelto.value and admtd=1 and fname=thisform.fname.value" ENDIF Select student.code ,; student.lcode ,; SUM(account.debit) + opdr AS dr ,; SUM(account.credit) + opcr AS cr ; FROM Student ; LEFT JOIN Account ON Student.code = account.code; WHERE date<=thisform.adate.value AND BETWEEN(month,m.monthfm,m.monthto); AND &add_if; ORDER BY lcode; GROUP BY student.code,student.lcode; INTO CURSOR my_cursor IF _TALLY > 0 Report Form (Alltrim(thisform.file.value)) Preview ELSE = Messagebox('Data not found for Selected Critarea', 32, product) Return .T. ENDIF