Search Tools Links Login

Delete Records using ADODB

Posted: 2019-10-04
By: DavidCostelloe
Viewed: 219

Filed Under:

VB6 Databases, VB6 Code Cache

No attachments for this post


Delete a record from a Combo Box selection Using Access Database.

Put a Combobox and a Command Button on a form

Create an Access Database


Form_Load
    With Combo1
        .Clear
        .AddItem "David"
        .AddItem "Bob"
    End With
End Sub

Public Sub Command1_Click()
    Dim MyConn As New ADODB.Connection
    Dim MySql As String

    With MyConn
        .ConnectionString = strJetProvider
        .Open
    End With
    MySql = "DELETE FROM SQL WHERE "
    MySql = MySql & " [Field] ='" & Combo1.Listindex(Combo1.List) & "'"
    MyConn.Execute MySql '* no need for recordset
    MyConn.Close
    Set MyConn = Nothing

End Sub

Special Instructions

This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
 


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.