Delete Record In other table using button

D

David

Hi,
I have a form in which a list is populated from a query of another
table. From this form I would like to use a button to delete a record
in the other table using a selected item in my list as the criteria.

I am sure this is probably fairly simple but I am not very good with
VB.

Any help would be appreciated!
Thanks
Dave
 
A

Arvin Meyer [MVP]

Assuming your Listbox has at least 2 columns, the first of which contains
the Primary Key of the record and has a zero column width. The code in the
double-click event of the listbox might then look something like this
(aircode) Set a reference to DAO:

Sub lstWhatever_DblClick(Cancel As Integer)

CurrentDB.Execute "Delete * From YourTable Where ID =" & Me.lstWhatever
Me.lstWhatever.Requery

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top