Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test if a field in a grid record has changed
Message
From
18/08/2009 08:38:35
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01418565
Message ID:
01418631
Views:
74
>Is there a quick way to test if any field in a record in a grid has changed.
>I need to save the record to a different table if data in any of the record's fields has changed.
>In the old days, I would make a copy of the table before allowing edits and then compare every record's field in each table when done.
>If there is an easier, faster way -- I would love to know.

GetFldState(-1) will return a string, with a byte for every field. For existing records, "1" means unchanged, "2" means changed. For example, "11211" would mean that the second field has changed (the first byte is for the "deleted" mark).

Note that the user can "touch" the data in a TextField; for example, type a character and then delete it with backspace - in this case, Visual FoxPro will also detect this as a "change". Should this be a problem, you can compare, e.g., Field1 with oldval("Field1").

All the above assumes buffering has been enabled. After a successfull TableUpdate(), both approaches would return information which means "no change".
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform