>I have been strugling with the concept of buffering for quite some time and hope someone can help.
>
>I have a grid that is bound to a table with 2 fields. The first is a code and the second is the description for the code. I want to be able to add new codes, changes the descriptions of existing codes, and delete existing codes. I added two text boxes underneath the grid for code and description.
That seems like a good idea. Editing directly in the grid causes some problems, especially when editing data which comes from related tables.
> I am not sure if I need to include the table in the dataenvironment.
Either that, or open it in the Form.Load() event.
> Also, I can't seem to figure out how to update the grid when adding or removing records from them. I have tried using the cursorsetprop and tableupdate commands, but I can't figure out the right combo to use them.
In Form.Load(), you would need something like this:
set deleted on
set multilocks on
use MyTable order "MyIndex"
CursorSetProp("Buffering", 5)
To save records:
if not TableUpdate()
local array laError
aerror(laError)
MessageBox("Can't save. Error #" + trans(laError(1)) + " " + laError(2)
endif
To undo changes:
TableUpdate()
ThisForm.Refresh()
> Sometimes I get the message this requires buffering, sometimes, the grid doesn't update. At one point it seemed to almost work for delete, but it would never delete the last record.
To delete a record, you must use TableUpdate(), too. Typical code might look like this:
if MessageBox... (ask user for confirmation)
delete
skip
if eof()
go bottom
endif
ThisForm.Refresh()
endif
If you forget the .Refresh(), it is possible that the changes are made, but don't appear immediately on the form.
HTH,
Hilmar.
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)