Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox Clears Itself
Hi!
I have a listbox on a sheet that is populated using an ODBC query to a SQLserver. The user selects two dates from calendar controls to form the query. The query is performed, and the listbox listfillrange is set to the query table resultrange. Next, the user makes selections from the listbox (MultiSelectMulti, ListStyleOption), and clicks a command button. This button goes through the selected items, and refreshes another ODBC querytable, modifying the where clause based on the selected item in the listbox. This all works well, except when the second query returns no rows. In this case, all of the user's selections in the listbox are cleared. Why? I stepped through the code - the selections are fine up to the refresh, then get cleared. If all of the subsequent querytable refreshes return data, the selections remain intact. Does anyone have any suggestions as to what I should be looking at in order to determine what is clearing the listbox selections? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox Clears Itself
Ok, I still don't know why this problem occurs, but a workable workaround is
to move the second querytable to a different sheet. When it returns no rows, the listbox selections remain intact and I can continue to loop through the listbox, executing the second qt.refresh based on listbox.selected(n) = true. The problem was that when the second query cleared the listbox, my loop was ending prematurely. "MikeT" wrote: Hi! I have a listbox on a sheet that is populated using an ODBC query to a SQLserver. The user selects two dates from calendar controls to form the query. The query is performed, and the listbox listfillrange is set to the query table resultrange. Next, the user makes selections from the listbox (MultiSelectMulti, ListStyleOption), and clicks a command button. This button goes through the selected items, and refreshes another ODBC querytable, modifying the where clause based on the selected item in the listbox. This all works well, except when the second query returns no rows. In this case, all of the user's selections in the listbox are cleared. Why? I stepped through the code - the selections are fine up to the refresh, then get cleared. If all of the subsequent querytable refreshes return data, the selections remain intact. Does anyone have any suggestions as to what I should be looking at in order to determine what is clearing the listbox selections? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting clears on opening | Excel Discussion (Misc queries) | |||
Moving section of cells clears instead!? | Excel Programming | |||
Worksheet_SelectionChange clears clipboard - can I stop this? | Excel Programming | |||
Really Need Help: side effect clears clipboard!!! | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming |