Loop through List Box

AccessKurzo

Dazed and Confused
Local time
Today, 16:57
Joined
Jan 5, 2001
Messages
55
How would you write the code to go through a List box, pull out all the indexes from selected rows(multi-select) and do an update query on each record?
 
Hi Kurzo,

you need to do a for each - items selected. You may also need to do a check for a null value as there can be nothing selected in the box sometimes,

For Each vItem In Me.lstBooked.ItemsSelected
myKey = DateConvert(Me!lstBooked.ItemData(vItem))
if MsgBox("Are you sure you want to cancel the " & Me!lstBooked.ItemData(vItem) & "?", vbDefaultButton2 + vbYesNo)=vbYes then
Let strSQL = "UPDATE yada yada yada WHERE KeyField=" & myKey & ";"
dbs.Execute strSQL
End If
Next


HTH

Drew
 
Thanks for your help Drew
smile.gif
 

Users who are viewing this thread

Back
Top Bottom