SELECT cusno,cusname FROM cusmas where .F. INTO CURSOR cusmas_srh readwrite && create an empty cursor to drive the grid Index on cusno tag cusnoThis will replace ALL the code you showed:
SELECT cusno,cusname FROM cusmas INTO CURSOR curtemp readwrite && A temp cursor SELECT cusmas_srh && Which drives the grid ZAP Append from dbf('curtemp') GO top Use in curtemp && Not really necessary thisform.grdClient.Refresh() thisform.grdClient.COLUMN1.SetFocus()NB! This is only my personal opinion, but I find the -> construct "old" and difficult to read. Instead I prefer the newer point easier to read, like cusmas.cusno .
>SELECT cusmas->cusno,cusmas->cusname FROM cusmas INTO CURSOR cusmas_srh ORDER BY cusmas->cusno >SELECT cusmas_srh >GO top >thisform.grdClient.RecordSource="cusmas_srh" >thisform.grdClient.Refresh() >thisform.grdClient.COLUMN1.SetFocus() >>