lnYear=YEAR(DATE()) SELECT MAX(BILLNO) from per WHERE YEAR(per.datein)=lnYear INTO ARRAY laAarray if _tally=0 laArray=1 thisform.text1.value=RIGHT(STR(10000+1,5),3) + '_' + (RIGHT(STR(lnYear,4),2)) else thisform.text1.value= RIGHT(STR(10000+per.billno+1,5),3) + '_'+(RIGHT(STR(YEAR(per.datein),4),2)) endif use per && file is in use Append From Dbf('temp') replace w1 with thisform.text14.value replace w2 with thisform.text16.value With thisform.grid1 .recordsource = '' Select temp .recordsource = 'temp' thisform.text1.SetFocus thisform.refresh endwith ********************** with thisform.Grid1 .Recordsource = .Recordsource endwiththanks