first is what field is your primary key? is it the dept_code or dept_name?
When i select a particular dept_name from the combobox i should get the corrosponding dept_code in the textbox.
Now, what you want is a little bit complicated
WHEN your primary is the dept_code.
Why? because if your primary is dept_code then it is very possible that there will be the same department name but have different code. right? so ergo, if you are going to select a department name the department code to be return will be the first department code saved in the database, thus you are not sure that the department code you are looking is the correct one.
regards.