Create a index tag on SubStr(faiuniqueid,4,4) and change your select:
lcYear=STR(YEAR(DATE()),4)
Select faiuniqueid From fai_required Where SubStr(faiuniqueid,4,4) = lcYear InTo Cursor myFAIlist
By including the date() into the where, VFP will have to evaluate date() for every record!
>I have a uniqueindex made like FAI2005-000001. It is based on the year the record was input. When a new record is added I need the last unique id plus 1. My SQL statement I use is:
>
>Select faiuniqueid From fai_required Where Val(SubStr(faiuniqueid,4,4)) = Year(Date()) InTo Cursor myFAIlist
>
>This sql statement runs very slow on our older computers. Is there a way to do this different to make it faster?