If you have a table, use index tags! Please, get this clear: Index on a table is done ONCE, and only ONCE, NEVER NEVER in a program like you do here. There is absolutely no reason why you should not use an index tag. You use VFP9, and t\you want speed. You get it with index tags!!!
>Is x2 a table or a cursor?table
>which index tags do you have for yoru table x2 ? i have no index i use index only via code
>index on f1 tag f1...f1 unique
> INDEX on f4 TO kk
>thanks
>
>
>>Is x2 a table or a cursor? If X2 is a table, which index tags do you have for yoru table x2?
>>
>>>thank you for reply,
>>>
>>>i try it as below it take between 1 to lesthan 2 Minutes? i think it must be faster
>>>
>>>mytable have more than 6 milion records
>>>
>>>CLOSE all
>>>USE x2
>>> INDEX on f4 TO kk
>>> *index on f1 tag f1
>>>lcTempVariable=ALLTRIM(thisform.text1.value)
>>>LOCATE fOR f1=lcTempVariable
>>>thisform.text2.value=f4
>>>lcTempVariable=f4
>>>SELECT f1,f2,f3,f5,f6 FROM x2 WHERE f4=lcTempVariable;
>>>order BY f5;
>>>into CURSOR mycur
>>>thisform.grid1.RecordSource="mycur"
>>>**COUNT TO s
>>>s=_tally
>>>
>>>
>>>>Sorry, my presed the wrong button...
>>>>
>>>>First of all, unless you work with cursors, INDEX shall NEVER be a part of normal code! Period! End of discussion! Instead you use a structural index. I believe I have said this before.....
>>>>
>>>>Secondly, you NEVER locate for an object value, instead you use a variable
>>>>lcTempVariable=ALLTRIM(thisform.text1.value)
>>>>LOCATE fOR f1=lcTempVariable
>>>>And later in your code:
>>>>thisform.text2.value=f4
>>>>lcTempVariable=f4
>>>>SELECT f1,f2,f3,f5,f6 FROM x2 WHERE f4=lcTempVariable;
>>>>order BY f5;
>>>>into CURSOR mycur
>>>>**COUNT TO s
>>>>s=_tally
>>>>
>>>>>Hi all,
>>>>>
>>>>>i try to see result at mygrid , but it is very slow operation,
>>>>>
>>>>>f1=national number
>>>>>f4=my file number as 00123/234
>>>>>
>>>>>at my grid i must see all records have the same file number
>>>>>
>>>>>USE x2
>>>>>INDEX on f4 TO kk
>>>>>LOCATE fOR f1=ALLTRIM(thisform.text1.value)
>>>>>IF FOUND()
>>>>>
>>>>>thisform.text2.value=f4
>>>>>SELECT f1,f2,f3,f5,f6 FROM x2 WHERE f4=(thisform.text2.value);
>>>>>order BY f5;
>>>>>into CURSOR mycur
>>>>>COUNT TO s
>>>>>thisform.grid1.RecordSource="mycur"
>>>>>
>>>>>ELSE
>>>>>MESSAGEBOX("not found")
>>>>>ENDIF
>>>>>
>>>>>
>>>>>thanks