Hi Jerold;
Your syntax error is due to the fact that you are trying to locate using a numberic value for your field name.
Assume the ATCLINE() finds your lastname value. ATCLINE() will return a number value pointing to the line number your lastname is located. If it is at line 1, ATCLINE() returns a 1. Substituting the 1 returned for the ATCLINE() in your code gives you:
locate all for 1 != 0
Why are you using the locate command if you have the file indexed. Locate starts at the first record and does a string compare all the way to your sought after record. Very time consuming. Try this instead:
sele &mytable
index on lastname + firstname to I
set exact off
** You might want to put the following here if you are
** checking for validity
**
** if ATCLINE(allt(thisform.txtname.value),allt(lastname)) !=0
seek thisform.txtname.value
do while thisform.txtname.value = lastname
*** your code here
enddo
else
***what happens if not found in ATCLINE()?
endif
Also, it is not good to reindex every time the user clicks. If you set up your table with an index, it will always (well, almost always) be pointing correctly for you. Change your index statement to set order to I once you have created I as the tag for that particular index.
sele &mytable
SET ORDER TO I
set exact off
*** and so on....
Remember to set exact back on if needed.
There are other ways to accomplish the same thing but I couldn't suggest more without knowing more about what you are trying to accomplish.