View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
MBlake MBlake is offline
external usenet poster
 
Posts: 33
Default ComboBoxOffence reading ComboBoxActivity

Hi Toppers,
Many thanks for your reply. I tried to suggested code but get an error on
the If Me.ComboBoxActivity line, I then changed the code to the below but
that failed in the same way.
================================================== ===========
Private Sub ComboBoxActivity_Change()

If Me.ComboBoxActivity.Value = "R.Sanctioned Detection" Then
Me.ComboBoxOffence.List = Sheets("sheet5").Range("C2:C7").Value
End If
If Me.ComboBoxActivity.Value = "R.Other Arrest" Then
Me.ComboBoxOffence.List = Sheets("sheet5").Range("D2:D4").Value
End If
If Me.ComboBoxActivity.Value = "X.Sanctioned Detection" Then
Me.ComboBoxOffence.List = Sheets("sheet5").Range("C12:C17").Value
End If
End Sub
================================================== ===========

TIA,
Mickey



"Toppers" wrote in message
...
Hi,

I think this is what you want. ListIndex is a numeric value specifying
the index (position) in the combo list whereas you are trying to compare
the
list values.

You might to change "ELSEIF" to IF... ENDIF i.e each IF is terminated by
END IF rather the single END IF in your code.

Private Sub ComboBoxActivity_Change()

If Me.ComboBoxActivity.Value = "R.Sanctioned Detection" Then
Me.ComboBoxOffence.List= Sheets("Sheet5").Range("C2:C7").Value
ElseIf Me.ComboBoxActivity.Value= "R.Other Arrest" Then
Me.ComboBoxOffence.List = Sheets("Sheet5").Range("D2:D4").Value
ElseIf Me.ComboBoxActivity.Value= "X.Sanctioned Detection" Then
Me.ComboBoxOffence.List = Sheets("Sheet5").Range("C12:C17").Value
End If
End Sub


HTH

"MBlake" wrote:

Hi,
ComboBoxActivity is populated from a TextBox. I am now trying to get
CombBoxOffence to populate from the value in ComboBoxActivity. I am
trying
the following code from Ron but ComboBoxOffence remains blank. TIA for
any
help, I have tried naming the Sub _Click() and _Change() to no avail.
Thanks,
Mickey

================================================== ===========
Private Sub ComboBoxOffence_Change()

If Me.ComboBoxActivity.ListIndex = "R.Sanctioned Detection" Then
Me.ComboBoxOffence.List = Sheets("Sheet5").Range("C2:C7").Value
If Me.ComboBoxActivity.ListIndex = "R.Other Arrest" Then
Me.ComboBoxOffence.List = Sheets("Sheet5").Range("D2:D4").Value
If Me.ComboBoxActivity.ListIndex = "X.Sanctioned Detection" Then
Me.ComboBoxOffence.List = Sheets("Sheet5").Range("C12:C17").Value
End If
End Sub
================================================== ===========