Delete A Record if Simple List Item Deselected

  • Thread starter Thread starter GDub
  • Start date Start date
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"?
 
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)));
 
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
 
Back
Top