Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Am I misusing TableUpdate()?
Message
 
À
15/09/1999 13:20:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00261437
Message ID:
00265162
Vues:
58
>>>He opens the view empty, and inserts records into it from an array. But these records are really representatives of records that already exist in the base tables, so when he does a TABLEUPDATE, he just wants to use the contents of the view to update existing records instead of insert new ones. VFP, seeing that the records in the view were inserted into the view as opposed to populated by a REQUERY(), naturally performs an INSERT SQL when the TABLEUPDATE command is given, and the result is a uniqueness error, because it is trying to add a record that already exists.
>>>
>>>Since VFP uses the fieldstate of the contents of the view to decide how to perform the update (INSERT vs UPDATE) I have advised him to try to trick VFP using the SETFLDSTATE function to change the "new" status of the records in the view to "current", so VFP will UPDATE the base tables instead of INSERTing into them. The current state of this is an error message stemming from code that I gave him that I can't put a finger on: the code works fine for me. Any ideas along this train of thought?


>>The solution, IMHO, is to use a vierw that fetches the records with SQL and then edit them and update.
>
>This is the way I would handle it too, I just assumed that there were special circumstances that warranted this strategy.
>


Here's why I attempted this strategy, I'm all ears for trying it another way. Right now the user stares at a form with no fields filled out. He clicks [find] and a modal form pops up and the user can search on different fields for different criteria. A grid is created after the search with checkboxes in the grid (btw, how do I center those in a grid field?). The user checks what he wants in the grid; corresponding records make it into an array. The user can then perform a different search (resulting in a new, requery'd grid) and check more boxes for records to edit. When he clicks [done] the entire array is returned to the calling form. The array rows are inserted into the view. The user can then edit this subset of records as he pleases. While in the main form, the user can also clikc [add] or [del] to add or delete records from the view. In the end, when he clicks [commit] the records are updated (if previously existing) or inserted (if new)into the base table.

Thanks for all your help!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform