Opus Tutorial:

Using Databases

Part 3: Adding Records to a Database

Getting New Data from the User

You are now able to display records from the database and allow the user to search for records. Now let's see how to allow the user to add new records to the database.

The following steps should allow you to modify the publication created in the first two tutorials to allow for the addition of new records:

  1. Open the example publication with which you have been working throughout the previous two tutorials
  2. Add a text input box to the page
  3. In the properties of the text input box, select the Text Input tab and click on the "New" button
  4. Create a new publication variable named NEWNAME with a default blank text value
  5. Click Apply and OK
  6. Now repeat steps 2-5 to create two more text input boxes, assigning the first to a new publication variable named NEWAGE (with a default blank text value) and the second to a new publication variable named NEWOCCUPATION (again with a blank text value)

Connecting the Data to a New Record in the Database

  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 Insert New 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 NEWNAME 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 NEWAGE variable
  13. Click on the OCCUPATION field to highlight it
  14. Enable the Variable radio button
  15. Now open the drop-down menu for the Variable field and select the NEWOCCUPATION variable
  16. Click Apply and OK to confirm the changes
  17. Now preview the publication
  18. Input some values into the three text input boxes (although the search input field should be left blank)
  19. Click the button underneath the three input fields to submit the information

To test that the information has been correctly added, simply exit out of preview mode, open your database back into Microsoft Access and view the contents of Table1. The inputted values should now appear as the last record in the table.

tutorial on connecting to a database with Opus Pro