Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating field based on combo box selection

Status
Not open for further replies.

hd2007st

Programmer
Nov 7, 2007
10
US
I have a combo box that contains dept numbers. I would like to update another field based on the dept number selection.

The "IfElse Then" statement works well when both fieds are text boxes. Does not work at all when selection is combo and the other is text.

Works:

Private Sub Dept_TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

If Dept_TextBox.Text = "t2550" Then
BusinessUnitTextBox.Text = "SPBU"
ElseIf Dept_TextBox.Text = "t2441" Then
BusinessUnitTextBox.Text = "SPBU"
ETC ......
End If

Doesn't Work:

Private Sub Dept_ComboBox_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dept_ComboBox.SelectedIndexChanged

If Dept_ComboBox.Text = "T2550" Then
BusinessUnitTextBox.Text = "SPBU"
ElseIf Dept_ComboBox.Text = "t2441" Then
BusinessUnitTextBox.Text = "SPBU"
ETC .......
End If

I know its simple but I am getting ready to throw something

Thanks







 
You need selectedText, selectedValue, or SelectedItem, depending on how you loaded the box.

You may want to consider a looser implementation than

If
Elseif
Elseif

Depending on how you are loading the combo boxes you may want to have a proc or function that loads the other box, based on a passed value.

-Sometimes the answer to your question is the hack that works
 
Thanks Much.

I am loading the combo box through data typed in items box.

Think I will come up with quick table that links department number with business unit and proc through that table.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top