I think you got the answer in the other thread, but just to make sure you understand this:
The reason the RECCOUNT() of Tmp is the RECCOUNT() of WorkDay is that
Tmp IS WorkDay with a SET FILTER done to it (by FoxPro 'in the background').
If you write a SQL SELECT command which can be done by FoxPro, 'in the background', simply doing a USE AGAIN, applying a temporary index (because of ORDER BY) and a temporary SET FILTER (because of WHERE condition), that's what FoxPro does. It doesn't create another actual table.
There are a few ways to
force FoxPro to make a separate physical table as the result of SQL SELECT. One is to add a field which doesn't exist in the original table. Another is to use the NOFILTER clause available since a certain version (3.0? 5.0?). SQL SELECT is also forced to create a separate physical result table if you're joining more than one table.
A specific suggestion about your code sample below. It's very unorthodox to use a FOR Counter=1 TO RECCOUNT() loop to move through the records of a table. (In fact you're the first person I ever saw do it ... congratulations on the original idea!) The normal way is either:
1) Old-fashioned but occasionally still useful:
DO WHILE NOT EOF()
do stuff
SKIP
ENDDO
2) Usually better than 1):
SCAN
do stuff
ENDSCAN
HTH,
Rich.
>I have found the problem .
>
>When I check the value of reccount() :
>Select tmp
>i = reccount()
>
>It should be the total record of tmp ,right ?
>
>But in fact ,it give me the total record of workday .
>
>Do you know why ?
>
>>You could do one of several things:
>>
>>1.
>>Select tmp
>>Locate
>>Scan
>>
>>
>>>Firstly ,here is the source code :
>>>
>>>---------------
>>>thisform.list2.CLEAR
>>>
>>>SELECT wname,wday FROM workday WHERE wday = date() ;
>>>AND NOT wname="blank" INTO CURSOR tmp
>>>
>>>SELECT tmp
>>>FOR i = 1 to RECCOUNT()
>>>GO i
>>>thisform.list2.ADDITEM (tmp.wname)
>>>endfor
>>>
>>>RELEASE tmp
>>>---------------
>>>The problem is I can prove that there is no record in tmp ,but when I run the program ,it added 3 item into list2 ! HOW COME ?! It make me crazy .
>>>Do you have any idea about that ?
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing