>function GetRecentFTE() > lparameters lcPermID > local closeit, lnFTE, lnFTE2, lnOldWorkArea > lnOldWorkArea = select() > closeit = used('pei') > select (fulltime + parttime) as tFTE ; > from new_pe_pei_database!pei ; > where PermId = lcPermID and _year <= year(date()) ; > order by _year ; > into cursor crsTempFTE > if _tally > 0 && If I found at least 1 record > go bott > lnFTE = tFTE > if ! bof() > skip -1 > endif > lnFTE2 = tFTE > use in crsTempFTE > if ! closeit > use in pei > endif > else > lnFTE = 0 > lnFTE2= 0 > endif > closeit = used('history') > if lnFTE = 0 && There was no data in PEI so ck the survey history > select surveys_distributed ; > from newsurveys!history ; > where PermId = lcPermID and _year <= year(date()) ; > order by _year ; > into cursor crsTempFTE > if _tally > 0 > go bott > lnFTE = surveys_distributed > else > lnFTE = 0 > endif > use in crsTempFTE > if ! closeit > use in history > endif > endif > select(lnOldWorkArea) > if lnFTE > 0 > return lnFTE > else > return lnFTE2 > endif >