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:
- Open the example publication with which you have been working throughout the previous two tutorials
- Add a text input box to the page
- In the properties of the text input box, select the Text Input tab and click on the "New" button
- Create a new publication variable named NEWNAME with a default blank text value
- Click Apply and OK
- 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
- Add a button object to the page
- In the actions for the button, select the Database group of actions
- Double-click on the Insert New Record action
- Open the drop-down menu for the DSN field and select the DSN you created in Part 1
- Open the drop-down menu for the Table field and select 'Table1' from the list provided
- You should now see all of the fields from the database appear in the grid below the DSN and Table fields
- Click on the NAME field to highlight it
- Enable the Variable radio button
- Now open the drop-down menu for the Variable field and select the NEWNAME variable
- Click on the AGE field to highlight it
- Enable the Variable radio button
- Now open the drop-down menu for the Variable field and select the NEWAGE variable
- Click on the OCCUPATION field to highlight it
- Enable the Variable radio button
- Now open the drop-down menu for the Variable field and select the NEWOCCUPATION variable
- Click Apply and OK to confirm the changes
- Now preview the publication
- Input some values into the three text input boxes (although the search input field should be left blank)
- 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.