Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete an ADO record 1

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
MS Access 2000 ADO database

Using a combo box the user selects an item from the pull-down list and then clicks a button to remove the item from the list. The combo box is populated from the field ITEMS in a table called PROPERTY

How do I get the code to search the table for the selected item and then delete it?
 
This is relatively easy. If the selected item from the combo is a unique table value you have enough information to do what you want. If it is not unique, from the table or query controlling the combo you will have to include the primary key as a hidden column in the combo box. If you fall in the second category and do not know how to hide the column, post back.

Dealing with the first situation, below is a subroutine which will do what you want. It does assume your selected value from the combo box is a string. The input argument is that string. Also the code is DAO since I do not use ADO. You can substitute as needed. The logic will be the same in either case.


Public Sub subDelCboRec(lookup As String)
Dim strSQL As String

strSQL = "Delete * from yourtable where litkey = '" _
& lookup & "'"
DoCmd.RunSQL strSQL

End Sub
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top