Change Label based on Two Combo Boxes

  • Thread starter Thread starter shmoussa
  • Start date Start date
S

shmoussa

Hi,

I currently have this code in AfterUpdate event for Combo2, hoping it
would change label1, but it does not work. :

If Me.Combo1.Value = "State" And Me.Combo2.Value = "2008" Or "2007" Or
"2006" Then
Me.Label1.Caption = "Select a State:"
ElseIf Me.Combo1.Value = "City" And Me.Combo2.Value = "2009" Or "2010"
Or "2011" Then
Me.Label1.Caption = "Select a City:"
Else
Me.Label1.Caption = "Select a Number:"
End If

The label does not change when I make changes to the combo1 and combo2
selections.

Any ideas?

Thanks
 
Hi,

I currently have this code in AfterUpdate event for Combo2, hoping it
would change label1, but it does not work. :

If Me.Combo1.Value = "State" And Me.Combo2.Value = "2008" Or "2007" Or
"2006" Then
Me.Label1.Caption = "Select a State:"
ElseIf Me.Combo1.Value = "City" And Me.Combo2.Value = "2009" Or "2010"
Or "2011" Then
Me.Label1.Caption = "Select a City:"
Else
Me.Label1.Caption = "Select a Number:"
End If

The label does not change when I make changes to the combo1 and combo2
selections.

Any ideas?

Thanks

Try the following syntax:

Me.Combo2.Value = "2008" Or Me.Combo2.Value = "2007" Or
Me.Combo2.Value = "2006"

although hard coded values are a bad thing IMO.

Keith.
www.keithwilby.co.uk
 
Back
Top