*!* this sorts main table by lastname, cLastSearch is
*!* value from textbox on search form
LPARAMETERS cLastSearch
SELECT 0
USE ALLTRIM(cfilepath) + 'prsimmig'
SET ORDER TO 4 && filter db by lastname
GOTO TOP
SET EXACT OFF
SEEK cLastSearch
IF FOUND()
SELECT 0
USE ALLTRIM(cfilepath) + 'ReportTable'
ZAP
DO WHILE cLastSearch = SUBSTR(prsimmig.lastname,1,LEN(cLastSearch))
SELECT ReportTable
APPEND BLANK
REPLACE ReportTable.lastname WITH prsimmig.lastname && transfers data to
REPLACE ReportTable.firstname WITH prsimmig.firstname && temptable
REPLACE ReportTable.id_num WITH prsimmig.A_Number
REPLACE ReportTable.date_in WITH prsimmig.date_in
REPLACE ReportTable.amount WITH prsimmig.amount
REPLACE ReportTable.rec_num WITH prsimmig.rec_num
IF EMPTY(prsimmig.out)
daysin = (DATE() - prsimmig.date_in)
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ELSE
REPLACE ReportTable.out WITH prsimmig.out
daysin = prsimmig.out - prsimmig.date_in
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ENDIF
SELECT prsimmig
IF EOF()
MESSAGEBOX ('Entry not found'+(CHR(13))+'...please retry',32,'Record Search Incomplete')
EXIT
ELSE
SKIP 1
ENDIF
ENDDO
DO tableformat && temptable stores data formated from reporttable
ENDIF
release cLastSearch
this may seem strange and it's a long story (all the tables and sorting) but the seek it's self is what you need to see I assume.