use table1
locate for username=thisform.text1.value
First of all, after putting a data table in USE, you should do a SELECT to ensure that the intended table is the one that is being worked upon.
Code:
use table1
[b]SELECT Table1[/b]
locate for username=thisform.text1.value
Next, the ability to use a LOCATE like you are doing can be dependent on a number of 'other' environment parameters.
Do you have
SET EXACT ON ?
* You can check by using ?SET('EXACT')
If so, then unless the full value of Username (including trailing spaces) is Exactly equal to the full value of thisform.text1.value (including trailing spaces) then LOCATE will NOT find a match.
For example:
MyTable.UserID = "12345 " && Note number of trailing spaces
cFindThis = "12345 " && Note different number of trailing spaces
LOCATE FOR MyTable.UserID = cFindThis
will not result in a FOUND() if SET EXACT ON
Actually, although I generally prefer to use a SEEK on an Indexed field, when I do a LOCATE for characters (whether numeric or alpha characters) I not only use ALLTRIM() but I also generally use UPPER() so as to eliminate any possible issues with character Upper/Lower Case mis-match.
Example:
LOCATE FOR ALLTRIM(UPPER(ThisField)) == ALLTRIM(UPPER(cFindThis))
* Also note use of double equal signs '==' which means EXACTLY Matches
That will better ensure that a match can be found if it exists at all.
Good Luck,
JRB-Bldr