04-17-2004, 03:55 AM
How can I delete an item from the listbox and database at the same time? For example: If I delete apple from the listbox, it should also be deleted from my database.
04-17-2004, 05:57 AM
After you have selected the Listbox item do:
(assuming you have an ADO connection opened)
oConn.Execute "Delete * From Table1 Where Field1= '" & List1.Text & "'"
04-18-2004, 10:18 PM
Thanks... I'll do it... :)
04-22-2004, 10:40 PM
Thanks to all your help I was finally able to run the program, so here's the code that I've used:
Dim adoRs As ADODB.Recordset
Dim adoCn As ADODB.Connection
Set adoCn = New ADODB.Connection
Set adoRs = New ADODB.Recordset
adoCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "dbnames.mdb"
adoRs.Open "Table1", adoCn, adOpenKeyset, adLockOptimistic
adoCn.Execute "Delete * From Table1 Where names= '" & List1.Text & "'"