I'm running Access 97 under Windows XP. On an unbound form, I have an unbound list box (lstItems) whose MultiSelect property is set to Extended, and whose RowSource is a select query; some of the query's criteria are based on the values in other fields on the same form. The application requires that, whenever the list box's selections are changed, I need to recalculate (a) the number of items selected, and (b) the sum of the values in a particular column in the selected items.
In the list box's AfterUpdate event procedure, I'm using lstItems.ItemsSelected.Count to determine the number of selected items, and the following code to compute the sum:
Dim PaymentsSelected As Currency, V As Variant, C As Currency
For Each V In lstItems.ItemsSelected
C = Nz(lstItems.Column(6, V), 0)
PaymentsSelected = PaymentsSelected + C
Next V
All this works fine in most cases. However, I've noticed that about 5 percent of the time something bizarre happens: holding the Control key down, I click on a particular item to select or de-select it and it gains or loses a highlight to reflect that change. However, neither the count nor the sum is updated. This occurs even though the AfterUpdate event is firing in all cases, and even if I add the following code:
lstItems.Requery: Me.Requery: Me.Repaint
Does anyone know why this is happening or how I can get around it?
In the list box's AfterUpdate event procedure, I'm using lstItems.ItemsSelected.Count to determine the number of selected items, and the following code to compute the sum:
Dim PaymentsSelected As Currency, V As Variant, C As Currency
For Each V In lstItems.ItemsSelected
C = Nz(lstItems.Column(6, V), 0)
PaymentsSelected = PaymentsSelected + C
Next V
All this works fine in most cases. However, I've noticed that about 5 percent of the time something bizarre happens: holding the Control key down, I click on a particular item to select or de-select it and it gains or loses a highlight to reflect that change. However, neither the count nor the sum is updated. This occurs even though the AfterUpdate event is firing in all cases, and even if I add the following code:
lstItems.Requery: Me.Requery: Me.Repaint
Does anyone know why this is happening or how I can get around it?