HandsOn Deleting a Record

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the Code window, enter the Delete_Record procedure as shown below.

Sub Delete_Record()

Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Dim strConn As String Dim strCriteria As String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & CurrentProject.Path & _ "\Northwind.mdb"

Set conn = New ADODB.Connection Set rst = New ADODB.Recordset

With rst

.Open "Select * from Employees Where LastName ='Marco'", _

strConn, adOpenKeyset, adLockOptimistic .Delete .Close End With

Part II

Set rst = Nothing Set conn = Nothing End Sub

0 0

Post a comment