Combo show/hide

L

LJG

Hi Guys,

I need to know how a combo box to only show if certain options are selected
on first combo box.

Any suggestions most welcome

TIA
 
R

Ron2005

On combo2 set the .visible=false

on afterupdate or onchange in combo1 do a case and on those that you
want it to be visible set the .visible = true.

Ron
 
R

Ron2005

Forgot to add.

on the oncurrent event set the visible to false otherwise it will
stay visible as you change records once it is visible.
 
L

LJG

Cheers Thanks for that Ron,

I have now got in my code:

Private Sub cbolead_AfterUpdate()
If LeadID = 32 Or 33 Then
cboSource.Visible = True
Else: cboSource.Visible = False
End If
If LeadID = 44 Or 45 Or 46 Or 47 Then
cboSource.Visible = True
Else: cboSource.Visible = False
End If
End Sub


As I could not see the oncurrent event, and was unsure which combo box to
use, the problem is that it's staying visible once I have updated it. Alsoit
becomes visible even when I select any item from the combo?

Any other tips please?
Les
 
D

Douglas J. Steele

Your code's not doing what you probably think is is.

I'm guessing that you're hoping that

If LeadID = 32 Or 33 Then

will be true if LeadID is 32 or LeadID is 33. It's not: it'll always be
true. That's because Access treats any non-zero value as True, so in essence
you're getting (LeadID = 32) Or 33. Since 33 is a non-zero value, you'll
always have True being ORed with whatever the result is for (LeadID = 32).

You need

If LeadID = 32 Or LeadID = 33 Then

Alternatively, you could use:

Select Case LeadID
Case 32, 33, 44, 45, 46, 47
cboSource.Visible = True
Case Else
cboSource.Visible = False
End Select


(In SQL statements, you could use If LeadID IN (32, 33) Then)
 
Top