Updating a recordset
In previous example, you learned how to add, update and delete records in a table by using SQL INSERT, UPDATE, and DELETE statements.In this example, you will learn the alternative way to add, update, and delete a record by using Recordset Methods.All records are populated in the list box; the first record displays in the two text boxes and that record is selected in the list box automatically(See Category Info3 form above).-If you want to add new records, click Save command button.The recordset comes over with 4 fields, only one of which is populated. These NULL values are meant to be updated within this function by referencing another table. Database Set db = Current Db Dim s SQL As String s SQL = "SELECT Deals. Creator, NULL As First Name, NULL As Last Name, NULL As Email " & _ "FROM tbl_Deals AS Deals LEFT JOIN tbl_Employee Aliases as Aliases " & _ "ON Deals.
To have a form as the figure above, you have to create the form in Form Design.
See the figure below: Note: Unselect Use Control Wizards before you drag these controls to the form.
- Drag and drop two text boxes, one list box and eight command buttons.
The saved record will display in the list box immediately.
-If you want to change category information, double click any record in the list box, make changing the category information(only category name is changeable) then click Update command button. -If you want to delete any record in a table, double click that record and click Delete command buttons.