Skip Headers

Oracle® Objects for OLE Developer's Guide
10g Release 1 (10.1)

Part Number B10118-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

Coding the Commit Button (Update and Add)

See Also
Quick Tour
Employee Form

The procedure for committing an update is similar for committing an Add, except that we place the dynaset in edit mode using DbEdit and then assign the new dynaset values.

Since we use the same commit button and the same commit event procedure to add and update, we introduce two global flags DoAdd and DoUpdate to distinguish between adding and updating. The Add and Update click event procedures set these flags.

The Commit event procedure for adding and updating does the following:

  1. Validates entered data. Handles errors when necessary.
  2. Uses DbAddNew to add records, else uses DbEdit for updates.
  3. Assigns entered data to dynaset fields, using the Fields().Value property.
  4. Updates database with new record, using DbUpdate.
  5. Disables the Commit button.
  6. Re-enables all other functional buttons including the Add and Update button.
  7. Sets the DoUpdate and DoAdd flags to false.
For clarity, we placed the data validation checks in Step 1 in a separate subroutine called DoValidationChecks(). We also moved the code that changes button and flag states in Steps 5 through 7 to a subroutine called SetAfterCommitFlags().

The code for the Commit function is broken into the following routines:

Commit_Click() Event Procedure

DoValidationChecks() Function

Update_Dynaset_Fields() Function

SetAfterCommitFlags() Subroutine