VBA LoadCombo If in a With?

J

Julibee

I'm using a With ... End With to load values in a combo box. Can use an If
statement in that? The values I'm expecting aren't all appearing.

I have boolean variables set True/False depending on the selection the user
makes in one combo box. There are options in the second combo that I only
want to show if they chose the appropriate value in the previous box.

Code looks something like this:
Select Case Combo1
Case 0
bReason1=True
...do some other stuff ... 'the other stuff is happening so it is
getting to here
Case 1
bReason2=True
...more code for other cases ...
End Select

then later on

With Combo2
.clear
.AddItem ("something")
If bReason1=True then
.AddItem ("something you can only have if you chose #1 in Combo1 above")
End If
.AddItem ("something completely different")
End With

Thanks!
Julibee
 
J

Julibee

ComboBox1.ListIndex is exactly what I'm using... (Well, to be totally honest,
for some reason I found I had coded ".Value" by mistake, but it seemed to be
fine that way. I've now changed it but it hasn't affected anything. Strange.
Probably VBA was doing one of those gratuitous data conversions for me.)

The variables are definitely not being set in the first combo box! (I threw
a debug.print in to check them and they are False)

Strangely enough, when the user makes a selection from ComboBox1 (which has
a much more descriptive name that relates to my app BTW), it is supposed to
set the variable, then make other labels and text boxes appear. They were
making their appearances exactly as expected so I assumed the variable was
being flipped as well, but ....

hmmm... well now the question is Why aren't they being set? Back to scanning
the code....
thanks!
Julibee
 

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

Top