Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with Buffering
Message
De
21/08/2004 16:31:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
21/08/2004 16:22:35
Randy Wessels
Screentek Business Solutions, Llc.
Phoenix, Arizona, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00935234
Message ID:
00935235
Vues:
19
>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:
* Form.Load()
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform