Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

*mytable is a variable *cmdfind.cl

Status
Not open for further replies.

jerold

Programmer
Aug 30, 2000
52
PH
*mytable is a variable
*cmdfind.click has this code

sele &mytable
index on lastname + firstname to l
locate all for ATCLINE(allt(thisform.txtname.value), allt(lastname)) != 0

*im receiving syntax error
*i guess its in the lastname parameter

pls help me..
thanks
 
What error message are you getting? Or what is not working?
-Pete
 
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.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top