Change Label based on Two Combo Boxes

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
 
K

Keith Wilby

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
 

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