>local lcFor, lnRecno, lcFilter, lcOrder, lcWhere >select yourtable store "" to lcFor, lcFilter, lcOrder, lcWhere >lnRecno=recno() >lcFilter=filter() >if !empty(m.lcFilter) > lcWhere=m.lcFilter >endif >lcOrder=order() >if !empty(m.lcOrder) > lcFor=for(tagno(m.lcOrder)) && Might be filtered index as well >endif >if !empty(m.lcFor) > lcWhere=m.lcWhere+iif(!empty(m.lcWhere)," and ","")+m.lcFor >endif >if !empty(m.lcWhere) > count for &lcWhere to thisform.NumberOfRecords && Attention, this might be slow, if FOR condition not optimizable and you have lots of records in the table >else > if set('deleted')="ON" && this affects number of records as well, if you have deleted records in the table > count to thisform.NumberOfRecords > else > thisform.NumberOfRecords=reccount() > endif >endif goto m.lnRecno >Ok, two minor corrections.