Clear unactive combo boxes

C

cfatz1

Hi-

I have 10 combo boxes that filter a report that is in a seperate sheet.
How can I clear all values that have been chosen in the non-active
combos so that each time the user selects the "Sort" Sheet they are
presented with blank combo boxes....EXCEPT for the one they just sorted
on? As of now, if I select one and then go back to the sort sheet, the
value I selected is still there for multiple selections that were made
in the past and is confusing to the user who wants to sort off only one
combo box. Each of these combos are independent of the others....you
can only sort by one.

I currently have this code on each of the Change commands for the
macros: (Note: I leave out the Active Combo box from the code but it
still clears that combo as well. The below example is for ComboBox1)

ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
ComboBox6.Text = ""
ComboBox7.Text = ""
ComboBox8.Text = ""
ComboBox9.Text = ""
ComboBox10.Text = ""

Hope this is clear! Thanks for helping me out.

-Chris
 
T

Tom Ogilvy

I suspect when you clear combox 2 in your example, its change event fires
and clears combobox1. You need to put in a boolean variable at the top of
the module

Public bBlockEvents as Boolean

then in each of your change events, check the state of that variable as the
first thing

Private Sub Combobox1_change()
if bBlockEvents = True then
exit sub
end if
bBlockEvents = True
ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
ComboBox6.Text = ""
ComboBox7.Text = ""
ComboBox8.Text = ""
ComboBox9.Text = ""
ComboBox10.Text = ""

' other code

bBlockEvents = False
End Sub
 
C

cfatz1

Tom-

This completely shuts off my combo boxes when the value is selected.
Nothing happens at all.

Any ideas?

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Loops 1
Advice rather than an actual question. 6
Refresh Problem 1
Form trouble 2
combo box 2
6 column sort 3
Auto Load 3
User form Text Box & Combo Box. 5

Top