Opus Tutorial:

Using Databases

Part 4: Modifying Existing Records in a Database

Introduction

There will be circumstances where data already in the database has changed. Let's suppose one of the contacts in the sample database has recently changed jobs, so we need to modify the OCCUPATION for this person's record. This section of the tutorial shows how you can modify an existing record in the database.

To do this, you first need to search for the relevant entry in the database, so that the record which needs to be modified is the current record. You can then use the Update Current Record action to modify the existing values. The following procedure should assist you in this:

Getting New Data

  1. Open the tutorial publication into Opus Pro
  2. Add a text input box to the page
  3. In the properties of the text input box, select the Text Input tab
  4. Select the NAME variable from the drop-down list of variables
  5. Click Apply and OK
  6. Now repeat steps 2-5 to create two more text input boxes, assigning the first to the existing AGE variable and the second to the existing OCCUPATION variable

Updating the Database with this Data

  1. Add a button object to the page
  2. In the actions for the button, select the Database group of actions
  3. Double-click on the Update Current Record action
  4. Open the drop-down menu for the DSN field and select the DSN you created in Part 1
  5. Open the drop-down menu for the Table field and select 'Table1' from the list provided
  6. You should now see all of the fields from the database appear in the grid below the DSN and Table fields
  7. Click on the NAME field to highlight it
  8. Enable the Variable radio button
  9. Now open the drop-down menu for the Variable field and select the NAME variable
  10. Click on the AGE field to highlight it
  11. Enable the Variable radio button
  12. Now open the drop-down menu for the Variable field and select the AGE variable
  13. Click on the OCCUPATION field to highlight it
  14. Enable the Variable radio button OCCUPATION variable
  15. Click Apply and OK to confirm the changes
  16. Preview the publication
  17. Type a search string into the search input field and click the button to display the matching record
  18. You should notice that the matching record also appears in the three text input boxes we have just added
  19. Click inside the text input box which is displaying the OCCUPATION variable and edit its contents to the new occupation of your contact
  20. Click the button to update the current record

To confirm that the record has been updated, simply exit out of the publication, then go back into preview mode and search for the original surname - no records will be returned. However, if you search for the new surname, a matching record should be displayed with the original NAME and AGE information.

tutorial on connecting to a database with Opus Pro