Form Default Value based on Combo Box selection

John P

Board Regular
Joined
Oct 17, 2002
Messages
108
I would like to have the value for Employee ID autopopulate based upon the Employee name selected from a drop down menu. Employee and Employee ID are two fields found on the same source table, so I think there needs to be a link, but am not very familiar with forms. Any assistance is appreciated. THanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You dont say where you want it to autopoulate to but, if you have built the combo using the wizard then you will probably find that you have the value already but are not displaying it!
You can probably just create an unbound text box and make its source "= [yourComboBox]"

HTH

Peter
 
Upvote 0
I am new to the forms, so please bear with me. I changed the control source to the employee combo box, but now the employee field and the employee ID field both display the employee name. My desire is to have the selection of the employee name populate the employee ID with the ID for the employee selected.

BTW, I did not create the combo with the wizard. I basically changed the employee text box to a combo box and made the row source type a Table/Query (created the query) and made the row source the Employee Name.
 
Upvote 0
Ok. If you are just after seeing the ID that goes with a name then:-
Go into the query for the employee name combobox and add the employeeID to the grid after the name.
Go back to the form letting the query save the changes.
In the property sheet for the combo box
Change the Column Count to 2
add a 0 width column to the Column Width field (2.54cm will become 2.54cm;0cm)

then for the control source of your employee field have =[cbotest].[Column](1)

This will update the ID when you change the name.
 
Upvote 0
Here is how I have it set up:
Employee field is a combo box. Control Source = Employee, Row/Source Type= Table/Query, Row Source = Employee Name, Bound Column = 1, Column Count =2.

Here is where I think I am lost....I set the Employee ID as follows:
Employee ID is a combo box. Control Source = Employee ID, Row/Source Type= Table/Query, Row Source = Employee ID, Bound Column = 2, Column Count =2 & Column Width = 0.

This does not autopopulated the Employee ID when I select the Employee. Where did I screw this up?
 
Upvote 0
I think that I may have confused things:(
When you say you want to populate the EmloyeeID do you just need to see the value or do you want to save it as well as the name? I was assuming that you have an employee table that the name was coming from and you were linking this to another table in the form.

peter
 
Upvote 0
The form is in place so that someone not familiar with the backend tables can populate test score results. The user would select the employee name from the combo box/dropdown menu, which autopopulates the employee ID field in the form (and the backend table). The remainder of the information is manually entered in the form, which populates the backend table. I would prefer the employee name selection to populate the employee ID field per the HR Data table (which is sourced via the Employee name query I created at the beginning of this process), so capture errors are not made in the employee ID since that is a primary key for several table links.
 
Upvote 0
I would actualy go along with the idea of saving the ID as that is the key field rather than the name. What usualy happens is that you use the wizard to create the combo to display the employee name but it actualy saves the ID number to your table rather than the name.
If you actualy create the combobox using the wizard you will see what I mean. The name shows but the ID is saved.

peter
 
Upvote 0

Forum statistics

Threads
1,221,657
Messages
6,161,084
Members
451,684
Latest member
smllchng5

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top