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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I append a record number within new groups

Status
Not open for further replies.

wilsong21

Programmer
Mar 4, 2006
7
US
I have a VF6 data file that IS ALREADY SORTED BY GROUPS AND I NEED TO ADD A SEQ NUMBER TO A NUMERIC DATA FIELD STARTING WITH 1 TO END OF THE GROUP FOR EACH GROUPS. THEN SORT WITHIN
EACH GROUP.

EXAMPLE
FRUITS SEQNUMBER

APPLES 1
APPLES 2
APPLES 3
APPLES 4
APPLES 5
PEACH 1
PEACH 2
PEACH 3
PEACH 4

HOW DO I DO THIS
 
I tried the above code and it puts the total count of all records in the last record. I am working on the code given above to make it work. Thank you for the starting point.

Thank you.
 
How about:

LOCAL nCnt, cFruit
SELECT FruitTable
INDEX ON Fruit TAG Fruit
LOCATE
m.cFruit = FruitTable.Fruit
m.nCnt = 1
SCAN
IF m.cFruit # FruitTable.Fruit
m.cFruit = FruitTable.Fruit
m.nCnt = 1
ENDIF
REPLACE SeqNumber WITH m.nCnt IN FruitTable
m.nCnt = m.nCnt + 1
ENDSCAN

Regards,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top