Download presentation
Presentation is loading. Please wait.
1
Adding, Updating, and Deleting Records from a Recordset
2
AddNew Method (ADO) Creates a new record in the edit buffer. The data are not actually written to the underlying database table until you call the Update method. Syntax: recordset.AddNew
3
Update Method (ADO) Saves any changes you make to the current record of a recordset object. The Update method must be called after the AddNew method. Syntax: recordset.Update
4
CancelUpdate Method (ADO) If you are editing a record, the CancelUpdate method will restore the contents of the current record to the values that existed before editing began. Syntax: recordset.CancelUpdate
5
Delete Method (ADO) Removes the current record from the recordset. Typically, the MoveNext method is called so that a current record will exist. Syntax: recordset.Delete
6
Private Sub cmdDelete_Click() rstCurrent.Delete rstCurrent.MoveNext If rstCurrent.EOF Then rstCurrent.MoveLast End If LoadCurrentRecord End Sub
7
Recordset EditMode Property Indicates the editing status of the current record. Returns one of the following values: –adEditNone –adEditInProgress –adEditAdd –adEditDelete Example: If rstCurrent.EditMode = adEditAdd Then cboMemberID.AddItem cboMemberID.Text, rstCurrent.AbsolutePosition – 1 End If
8
Private Sub cmdUpdate_Click() If cboMemberID.Text = rstCurrent("Member ID") Then CopyFields rstCurrent.Update InitialState ElseIf rstCurrent.EditMode = adEditAdd Then CopyFields rstCurrent.Update cboMemberID.AddItem cboMemberID.Text, rstCurrent.AbsolutePosition - 1 InitialState Else cboMemberID.RemoveItem rstCurrent.AbsolutePosition - 1 CopyFields rstCurrent.Update cboMemberID.AddItem cboMemberID.Text, rstCurrent.AbsolutePosition - 1 InitialState End If End Sub
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.