I have an extremely simple app - 1 table, with 1 form (MS Access 2003).
I have 2 combo boxes & 2 text boxes on my form. I w g text boxes with another field from that record. So ultimately I’ll be displaying four fields from two records - one in each combo box and one in each text box.
Can some one please provide (or point me to) a code-snippet that does this? I thought it would be an extremely simple “After Update” event in the combo box. But I couldn’t find any example on the web. At least, none that I recognized as doing what I wanted.
Umm, unless I’m misunderstanding, you don’t need any code to do this. Just…
for form properties, data tab, set the ‘record source’ to be your table.
Under properties of your textboxes and comboboxes, data tab, set the ‘control source’ to be the appropriate field of the table.
(Getting to form properties can be a little tricky. In Access 2000 you can click on a little box in the upper left hand corner of the form window - where the two ruler bars would intersect, and then hit the properties toolbar button, the one with a little hand.)
Once you have those properties set, Access should handle displaying the field values all by itself… that’s one of its most useful features. Hope that helps!!
Anyway, I think that what you are trying to do is select a field from a record with a combo box, and show another field from the same record in the text box.
The fact that you have two pairs of combo/text box is unimportant - once you have set up one pair it can be cloned as many times as needed. Although it is important that the combos are pulling records from a table that is NOT the bound table for the form, otherwise when you change one, the other also changes (not what you want!).
There is more than one way to do this, the easiest is to have all the fields in the combo box, but just display one. e.g. the combo’s record source could have 3 fields: key field, text box display field, combo display field. The column widths of the combo would be 0;0;2 so that only the 3rd field is seen in the combo.
Then set up the After Update event as follows:
Private Sub cboEmp1_AfterUpdate()
txtAddress1 = cboEmp1.Column(1) 'columns are numbered from 0, column 1 is address
End Sub