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

Scan not working 1

Status
Not open for further replies.

pkdata

Programmer
Jun 15, 2012
14
US
Don't know if anyone can help me out here. I have a table with 30 fields, one of which is a numeric field. This field is not populated for every record in the table and I need to copy the value of this field for next ? quantity of records until the numeric field is populated again.
Example, I have a numeric recno assigned to multiple records in the table and need to repeat the value of the first instance until there is a second value in the same field. Then I need to replicate that value in all the following records until a third value is present and do the same thoughtout the entire table. I have a total 40 different values in the numeric field and wanted to use a scan, but have been unsuccessful. Any suggestions? Thanks in advance.
 
I hope you mean that this is something you need to do to clean up your existing data. In general, you should never rely on the physical order of records in a table.

Try something like this. I'm assuming your table is called MyData and the field in question is called nRecno.

Code:
LOCAL nCurRecno

USE MyData

* Initialize to a value that cannot occur in nRecno
nCurRecno = -1

SCAN
  IF EMPTY(MyData.nRecno)
    REPLACE nRecNo with m.nCurRecno IN MyData
  ELSE
    nCurRecno = MyData.nRecno
  ENDIF
ENDSCAN

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top