Delete a single record instead of entire recordset



I would like to delete a single record, however the result of my
code
is that the complete recordset is deleted

Can anyone help me out here????

Here is my code


Sub DeleteAdvisor()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim OfferDB as String
dim advisorid as string

Set cnn = New ADODB.Connection

With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open OfferDB
End With

Set rst = New ADODB.Recordset

With rst
' Open the Recordset object.
advisorid = "12"

strSQL = "SELECT * FROM Qry_Invul_Adviseur WHERE Adviseur_id =
"
& advisorid
.Open Source:=strSQL, _
ActiveConnection:=cnn, _
CursorType:=adOpenKeyset, _
LockType:=adLockOptimistic
End With

rst.MoveFirst
rst.Delete
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub

.



Relevant Pages

  • Re: Exporting data from an append table into excel without field h
    ... this is the most simple code to export to excel using copy from recordset. ... Dim objXLApp As Object 'Excel.Application ... Set rst = CurrentDb.OpenRecordset ... Set objXLWs = objXLWb.Worksheets ...
    (microsoft.public.access.externaldata)
  • Re: Who Is Logged On?
    ... Dim cnn As ADODB.Connection ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ... Dim strUsers As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: A command button (Access) that saves the current record in a file
    ... 'In the onclick event of command button ... Dim fso As New FileSystemObject ... Set rst = Me.frmTextFileDemoSub.Form.RecordsetClone ... 'set recordset object rst to current record ...
    (microsoft.public.access.externaldata)
  • Re: Need help opening ADO recordset.
    ... key to a table using a query or DAO VBA. ... Dim cnn As ADODB.Connection ... Set cnn = CurrentProject.Connection ... the Recordset object. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Excel ADO Crash
    ... One other important point: the recordset ... Dim cnt As New ADODB.Connection ... Set cnt = New ADODB.Connection ... Set rst = New ADODB.Recordset ...
    (microsoft.public.excel.programming)