Multi-Select listbox will not clear selected lines

JDB

Registered User.
Local time
Today, 14:25
Joined
Mar 10, 2013
Messages
13
Good evening from San Diego

I have a multi select listbox that I rebuild as I index thru some products in another listbox. This listbox then gives me the ingredients I can use. Works well, but the ghost selections in the listbox stay hilighted even after the rebuild.

I can select and de-select at will if there are actual items in the list box, but the ghosts remain.

Here is the code to clear the listbox

Dim _
ctlSource As Control, _
varSelected As Variant, _
intListCount As Integer


Set ctlSource = Forms.frm_select_UPC_LoinGrade!lstBox_ColdStorage

For intListCount = 0 To ctlSource.ListCount
ctlSource.Selected(intListCount) = False
Next intListCount

Forms.frm_select_UPC_LoinGrade.Refresh
Forms.frm_select_UPC_LoinGrade.Repaint

------------------

Any suggestions are welcome


JDB in sunny San Diego, Ca
 
Define "rebuild" and "ghost selections".

Also, your loop is likely to get interesting when intListCount=ctlSource.ListCount, in a zero-based index.
 
Ans to the question;

in one listbox (A)I have a list of distinct UPC of a product(SingleSelection) that requires a certain tonnage of ingredients. When I select(Hi-lite) that UPC a query is run that shows a list of ingredients by source that can be used in that product in Listbox B. There may be 1 (lot) ingredient /source or 10 (lots) ingredient/sources. Each possible selection has the tonnage attached. If the first selection has enough tons for the UPC it reduces the tonnage available for the next UPC, if that ingredient can be used for that UPC.

When I select one or more of the ingredients, the selection is hilighted in Listbox B. I press a button and the required inventory is added to a new table and the previous inventory is reduced or zeroed out. All works well.

If I have selected a bunch of lots (ingredient by source) the Listbox B remains hi-lited in the position those lots were ( i call them ghosts). Now I select a new UPC, and listbox B is rebuilt with new lots ( ingredient and tonnages, but the hi-lited ghosts remain, if there is not enough lots to fill the listbox. If the area is hi-lited the selection cannot be made, so I click twice to de-select and re-select and then the process works again.

I am trying a DoEvents command before and after the Refresh or Repaint commands, but that is not working either.

Any suggestions welcome.

JDB
 
Found the solution by using listbox.rowsource = Something

-------------
Dim _
ctlSource As Control

Set ctlSource = Forms.frm_select_UPC_LoinGrade!lstBox_ColdStorage

ctlSource.RowSource = ""
ctlSource.RowSourceType = "Table/Query"
ctlSource.RowSource = "qry_160_Loin_Tons_Available"
-----------------------

Works well in getting rid of my ghosts - a ghost buster as it were.
 

Users who are viewing this thread

Back
Top Bottom