Try indexing the table and store the year in a variable so that it is not evaluated on each record:
INDEX ON Val(SubStr(faiuniqueid,4,4)) TAG VS_FAIUn
lnYear = Year(Date())
Select faiuniqueid From fai_required Where Val(SubStr(faiuniqueid,4,4)) = lnYear InTo Cursor myFAIlist
HTH
>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?