Add the lecturer name as the second column of the combobox row source
This is Column(1) as numbering starts at zero
You can hide the column if you wish.
In the after update event of the combo, add a line
Code:Me.TextboxName=me.Combobox.Column(1)
Where is the combo placed - on bound or unbound form?
Why does user need to see Lecturer_ID? Usually combo boxes are used to select an ID displaying some text (p.e. name) instead when the ID is selected and later when the form is displayed. I.e. you have a combo box with label "Lecturer", when you activate it you see a list of lecturer names, you select one of them, and the combo box value is set to selected lecturer's ID. And until the value of combo box is not changed, the name of selected lecturer is displayed.
Combo boxes are used mainly for following purposes.
1. You select a value for form field from predefined (in design, or in some table) list of values;
2. You have a record active in form, and you need to select a value for foreign key in this record. P.e. you need to attach a lecturer to specific course. In this case you set this foreign key as combos ControlSource, then you set a query which returns this foreign key as first column, and according text (p.e. name) as second column (there may be more columns, one is the minimum, but for your case 2 is the right number) as RowSource, set BoundColumn to 1, ColumnCount to 2 and ColumnWidth to "0;2.5" (the 1st column with non-zero width is displayed);
3. You have a form, and you need to select a specific record (with specific primary key value) to be active in form. You create a combo like in p. 2., but unbound one - i.e. you leave ControlSource property empty. And you have to design an AfterUpdate event to locate a record in form with primary key equal with one selected in combo, and set this record to be active.
Hi Riders52,
It worked. Thanks Alot
You're welcome but do note the points made by Arvi about using combo boxes