looping through all items in a list box

cocowomble

Registered User.
Local time
Today, 02:32
Joined
May 25, 2014
Messages
25
hi all.

I'm struggling with what is probably a very simple solution, and would like some help.

I have managed to amend records based on the user selecting multiple items in a list box by using the following code.

Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Usage", dbOpenDynaset, dbAppendOnly)



Set ctl = [Forms]![frmsearch]![lstSelector]
For Each varItem In ctl.ItemsSelected
rs1.AddNew
rs1!ID = ctl.ItemData(varItem)
rs1!UsageDate = Me.txtDate
rs1!PlanReturnDate = Me.txtplanReturn
rs1!District = Me.lstDistrict
rs1!Notes = Me.txtnotes
rs1.Update

what I need to do now, is to loop(I think) through and amend all the records in a populate listbox, with no selections, similar to above, but without selection.

would really appreciate any help you could give.

thanks in advance
 
Can't you just replace the ItemsSelected with the ListCount?
 
Can't you just replace the ItemsSelected with the ListCount?

would I still need
For Each varItem In ctl.listcount
.....
next

??
 
If you want to do stuff with the rows which are NOT selected
Code:
for intRow = 0 To ctlSource.ListCount - 1 
   if not ctlSource.selected(intRow) then 
      'Do your edit stuff using ctlSource.Column(X, intRow) 
   end If 
next intRow
 

Users who are viewing this thread

Back
Top Bottom