ComboBox oculta ComboBox

marceloDC

30-10-2015 17:53:55

Boa tarde amigos, estou tentando ocultar ComboBox através de outra ComboBox, conforme abaixo:
Private Sub ComboBox2_Change()
If ComboBox2 = "3" Then
ComboBox3.Visible = True
ComboBox4.Visible = False
ComboBox5.Visible = False
End If
If ComboBox2 = "4" Then
ComboBox4.Visible = True
ComboBox5.Visible = False
ComboBox3.Visible = False
End If
If ComboBox2 = "5" Then
ComboBox5.Visible = True
ComboBox3.Visible = False
ComboBox4.Visible = False
End If
End Sub
só que gera erro, qual seria a forma correta?
Obrigado pessoal!

Reinaldo

30-10-2015 18:29:37

Qual erro gerado?, de maiores info e poste um modelo

Edcronos

30-10-2015 19:55:35

use value quando pegar valores de combo ou textbox

ComboBox2.value
e vc pode fazer um loop

Código: Selecionar todos

Private Sub ComboBox2_Change()
a=val( Me.ComboBox2.value )
  for n=1 to 5
      if a=n then 
          me.controls("ComboBox" & n).Visible = True
     else
          me.controls("ComboBox" & n).Visible = False
  end if
next
end sub