> Dear Friends,
>
> I had this mind boggling problem with updating a view through a grid, and it took me days to figure out the real problem.
>
> Finally I located one of the culprits. But I need to know how the course for reform.
>
> I realised that in a view that is updateable through a grid, if I make a change to one of the cells, and move to the next cell by using the mouse, or the down arrow, I get the error 'View XYZ contains uncommitted changes'. However, if I commit the change in the cell using the 'Enter' button, no problem.
>
> Why is this happening, and how do I resolve it?
Hello Steve -
The error 'View XYZ contains uncommitted changes' itself sound as if your code (perhaps in grid.AfterRowColChange?) is attempting a Requery('yourView') before you made a TableUpdate() attempt (or a Tablerevert(), respectively).
I believe you do not want that Requery() at that point, in the first place.
Does that help?
Don't keep on reading if you know this already:-)
Default buffering of Vfp Views is 3 (optimistic row buffering).
That means each record pointer move causes an implicit TableUpdate() attempt on a modified row.
But TableUpdate() can return False, so you may not want the implicit one but rather do an explicit TableUpdate() programmatically (so that you can use AError() if it had returned False).
When you allow editing directly in a Grid, the alternate way would be to use buffer mode 5 (optimistic table buffering). That way you do not need to prevent moving record pointers.
So you could have a "Save" button somewhere next to the Grid (and a "Revert" button, too).
Anyway, you can only Requery('yourView') after your TableUpdate() or Tablerevert() methods have been done.
hth
-Stefan