Delete A Record if Simple List Item Deselected

G

GDub

I have a Simple Extension list box named PartList on my
Main Form. When a line item selection is made, the list
box Part, Desc and are successfully appended to a Material
Subform.

Is there a way to remove any appended line item on the
subform when the corresponding selected list box item
becomes deselected "On Click"?
 
W

Wayne Morgan

By Simple Extension do you mean a Simple Multiselect Listbox? If so, you
could create a list of the selected items then run a delete query on the
recordset feeding the subform and delete any records for the current order
id that aren't in the list of selected items.

Example:
DELETE Table6.OrderId, Table6.ItemID, *
FROM Table6
WHERE (((Table6.OrderId)=3) AND ((Table6.ItemID) Not In (1,4,6)));
 
W

Wayne Morgan

I thought I had changed the query before copy and pasting. It should be

DELETE *
FROM Table6
WHERE (((Table6.OrderId)=3) AND ((Table6.ItemID) Not In (1,4,6)));

You would concatenate the order id and selection list into the SQL then use

CurrentDb.Execute strSQL, dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top