What is the best way to delete multiple records selected from a list box?
Multiple Select to Delete Records
Collapse
This topic is closed.
X
X
-
Graham SwindonTags: None
-
Rich P
Re: Multiple Select to Delete Records
If the listbox is listing the items contained in a field(s) of a table
(say tbl1), then these items would serve as the "Where" criteria to
delete from.
Docmd.RunSql "Delete * From tbl1 Where fldx = '" & list1.Column(0) & "'"
For multiple selections of a listbox do this
Dim v As Variant
For Each v In List1.ItemsSele cted
Docmd.RunSql "Delete * From tbl1 Where fldx = '" _
& List1.ItemData( v) & "'"
Next
Note: if the items in your listbox (list1 here) are text (or alpha
numeric) you have to delimit these items with single quotes (') inside
the sql statements as I have done. For Dates the delimeter is a #
symbol.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment