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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display of Values in a form using Text Boxes

Status
Not open for further replies.

umbrau44

Technical User
Jan 16, 2003
5
CA
I am working on a database in Access 2000 and I want to display a value in text box based on the option that is selected in a combo box. Specifically, an employee number is picked from the combo box, and I want to display the employee's first and last name in the text box. The employee ID, first and last name are all stored in one table with the employee ID as the primary key, and the second table will contain the employee ID multiple times along with other information.
I have tried setting the control source in the text box to the employee ID selected in the combo box and then set the default value to the employee first name & employee last name, but only the first name appears. The default value seems to make no difference in what appears because I can put anything in the default value, and only the first name will appear.

I imagine the solution is not particularly difficult, but I haven't really done much database creation and I don't have a clue where to go from here.

Lincoln
 
Use the click event on the properties of the combo box. The code to use is

me.text0 = me.combo0 ' this is the bound column

me.text0 = me.combo0.column(0) ' this is col zero
me.text1 = me.combo0.column(1) ' this is col 1


etc
etc

Rollie E
 
Thank you for the help, that definitely works. However, it doesn't update quite like I expected (I barely know enough to ask the right questions!). I also added that code to the On Enter event in the combo box so that it would update as I look through the records. However, this only works if the combo box has focus. If it was just for me, I wouldn't care, but I would like it to update whenever the record is accessed. Is there some sort of event for this? Since I don't know any better, is it possible to attach this bit of code to the navigation buttons in the form?

Lincoln
 
Lincoln,

It sounds like you should use the on_current event so that it updates with each new record.

Rollie
 
That's the event I was looking for. For some reason, I didn't manage to find the form properties last week.

Thank you for the help,

Lincoln
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top