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

Check for changes in a cursor 1

Status
Not open for further replies.

bobmpalmer

Programmer
Aug 19, 2003
161
GB
I may be having a dumb moment here... I have a Select cursor with 5 fields in that I use to populate a grid on a form. The grid is user editable but my users are experts at closing forms without saving changes!!

Is there a simple way I can check in my form validate if the cursor or any field value has changed? Typically the cursor will only contain 3 or four records, but a change can be as minor as adding a period (.) to the end of a line.


Bob Palmer
The most common solution is H2O!
 
The GetNextModified() function tells you the record number of the next modifed record.

Especially GETNEXTMODIFIED(0,"cursoralias") tells you the recordnumber of the first modifed record, and if that call returns 0, then there are no changes in the buffer of the cursor.

Bye, Olaf.

 
Thanks Olaf, it's not a buffered table just a simple memory cursor created to populate the grid.

The problem is that the underlying table has a History function and I only want the user to save actual intentional changes. The form is used to view data and I don't want to force a save if a change has not been made. The data is NOT stored as displayed so I can't compare whats in memory with the underlying table.

Bob Palmer
The most common solution is H2O!
 
You can make the cursor buffered to use this. If the cursor is not buffered you will need to store start values and compare with final values, I tink using buffering would make this a whole lot easier, you can then also use GetFldState() to find the exact fields, which changed.

Also a history of records I'd rather do with insert/update/delete triggers and that would also only occur due to new/changed/deleted records, you don't have to check at all then.

Bye, Olaf.
 
Ok well I can't enable buffering as I have to ZAP this table each refresh as records are scrolled.

I've solved it by scanning and concatenating the TRIMMED(field values) into a form var on entry then doing the same on close and comparing the two values as you suggested Olaf. Many tks.

Bob Palmer
The most common solution is H2O!
 
You can, use tableupdate or tablerevert, then the buffer is empty and you can ZAP.

Also it's questionable you need a ZAP in the cursor at all. Why? Is it a 1:many situation and the grid displays the many records? Then you can still as said tableupadate() the cursor, even if it's not bound to a table it will be ZAPable then, or you could add to the cursor, index on it's foreign key and SET KEY TO.

Seems like your mechanism are so far away from the intended use of buffers you need to roll your own modification check. On a larger time scale I'd rethink your software design.

Anyway, glad to have given you an idea to compare before/after.

Bye, Olaf.
 
Olaf, The cursor is loaded with data stored in a memo field in an underlying table and displayed in the grid. As the user scrolls through the table the values change record on record and zapping the table clears the cursor, it is refreshed from the next memo field then displayed. I'm sure there are a dozen ways of doing it, but this one suited me and worked.

Tks

Bob Palmer
The most common solution is H2O!
 
If this is simple enough for you, ok. You can tablerevert the cursor, set it's buffering to 1 (no buffering) and then zap it, you could also simply close the cursor and recreate it.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top