Link a Textbox to a Combo Box

flester

New member
Local time
Today, 04:53
Joined
Aug 26, 2002
Messages
8
Developing a dB to log support calls.

Main form has a combobox where user's name is selected. I want to add a text box which will automatically show the user's company when name selected.

Control source for Combo contains tblUsers.name

I want txtCompany to automatically show tblUsers.Company for the selected user.

How do I do it?
 
There are a couple of ways to do this. Add the company name to the combo that you use to select the user and make that column width "0". On the after update event of the combo do:

Me.txtCompany = Me.comboname.column(2)

Column 2 is assuming you have a user id field (column 0) and a user name field (column 1) and then the company column.

Then, when you select the user their company will automatically appear in the text box

Another way is to add the user table to the query for your main form and link it to the main table. Take the company name field from the user table and add it to the query grid for the form. Create a text box that has the company name as it's control source. When you select the user, the company name will appear. That's my preferred option.
 

Users who are viewing this thread

Back
Top Bottom