Search Tools Links Login

Delete Records using ADODB


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

About this post

Posted: 2019-10-04
By: DavidCostelloe
Viewed: 247 times

Categories

Visual Basic 6

Attachments

No attachments for this post

Special Instructions

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


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.