Microsoft
Software
Hardware
Network
Question : problem of do while loop iin foxpro
I have a table named "output", like below:
type sales Trank
small 100.00 0
small 55.5 0
small 213.10 0
large 76.12 0
large 12.00 0
medium 2133.1 0
medium 66.88 0
medium 424.11 0
while the result should be add the rank to the different types like:
type sales Trank
small 100.00 2
small 55.5 3
small 213.10 1
large 76.12 1
large 12.00 2
medium 2133.1 1
medium 66.88 3
medium 424.11 2
my program code:
SELECT 1
USE output
INDEX ON type TO key
SET INDEX TO key
GO top
rankno = 0
DO WHILE !EOF()
SEEK "SMALL"
IF FOUND()
REPLACE Trank WITH rankno
ENDIF
rankno = rankno + 1
IF !FOUND()
WAIT WINDOW "NO RECORD"
LOOP
ENDIF
SKIP
ENDDO
CLOSE ALL
but it prompted me with "no record..."
and I tried another code:
SELECT 1
USE output
SCAN
rankno = 1
FOR lnI = 1 TO FCOUNT()
IF ALLTRIM(EVALUATE(FIELD('ty
pe')))='SM
ALL' then
replace Trank WITH rankno
endif
rankno = rankno + 1
NEXT
ENDSCAN
but I got ALL fields under column "type" filled with 8.....
pls kindly help...
Answer : problem of do while loop iin foxpro
USE output
INDEX ON type+str(sales) tag typesales descending
do while not eof()
lcType=type
lnRank=0
SCAN WHILE lcType=type
lnRank=lnRank+1
REPLACE TRANK WITH lnRank
ENDSCAN
ENDDO
Random Solutions
How to create a Form for data view
Importing/Linking Data from URL
How do you Erase or Clear all fields within the word document?
Understanding datasheet view
Want to update a field with values from another field within the same table if it meets a condition
appending MDB files to a single MDB
Can't save Access 2003 report with specific printer under Access 2007
Create report out of crosstab where column name changes
How to explore disk raiding status in Win2k3Server
The proposed new database owner is already a user or aliased in the database. (Microsoft SQL Server, Error: 15110)