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!

Indexing a numeric order in a grid on a form

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
337
GB
Hello

I am looking for advice on how to display a set of records in a specific order within a grid.

A couple of my employees supply statements. Sometimes, they supply more than one statement. My table has a field called WITNO (This is the actual witness number) and WSTATNO (This is the statement number they have provided as this could be 1, 2, 3 etc)

I have tried the following:

Code:
tempfile=SYS(3)
SELECT * FROM MYFILE WHERE MASTLINK=mmastlink ORDER BY ;
  WITNO, WSTATNO INTO TABLE tempfile+'.dbf'

The above puts the records in order:

1, 1
1, 2
1, 3
2, 1

So that’s fine because the order is correct however, if I add a record to employee 1 and make it statement 4 (so effectively it would be 1, 4 the order on the grid after adding the record shows:

1, 1
1, 2
1, 3
2, 1
1, 4

Where it should show:

1, 1
1, 2
1, 3
1, 4
2, 1

I have tried reversing the field names on INDEX but do not get the desired result in the grid.

Just one other thing, every time I add a record, the tempfile+’.cdx’ file is deleted and a new one created (I tried this just in case):

Code:
INDEX ON WITNO+WSTATNO1 TAG WITNO

What am I doing wrong please?

Steve
 
Once the records are either updated or new ones added yes. The original records are deleted and the ones in the sys(3) file are appended back to myfile.dbf

I will point out (only because I would consider it professional malpractice not to) that this is probably the worst possible way to do it. Everything about VFP is completely built to make this sort of activity unnecessary.

There. I've got that off my chest.
 
Hi danfreeman

I'm not going to argue with your observation as I'm still learning this language and I am aware that I need at some point to look into record locking etc.

Early days, early days....

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top