Delete Records using ADODB

By | 2019-10-04

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

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.