Have a form with a combo box field named "dist_code" where the user can
select a district code; in the field next to the combo box in the form there
is a text field named "district". I would like for the long description of
the district code to auto populate the text field accordingly. As an
example dist_code "PAU" in the combo box would expand to "Port Authority" in
the text field. I have a table named "district_tbl" with two columns,
"dist_code" and "disttrict". Any idea on how to do this? Much thanks in
advance for your help. Again Thanks.
George
Carl Rapson - 31 Aug 2007 21:34 GMT
> Have a form with a combo box field named "dist_code" where the user can
> select a district code; in the field next to the combo box in the form
[quoted text clipped - 9 lines]
>
> George
In the AfterUpdate event of the combo box:
Me.district = DLookUp("district","district_tbl","dist_code=" &
Me.dist_code)
If you populate the combo box with both dist_code (column 0) and district
(column 1), this could be simplified:
Me.district = Me.dist_code.Column(1)
Just as a note: it's not usually a good idea to give your form controls the
same name as the field they're bound to. Sometimes things can get confused.
Carl Rapson
KARL DEWEY - 31 Aug 2007 22:02 GMT
As an alternative you can display both in the combo box like this --
SELECT [dist_code], [dist_code] & " - " & [disttrict] FROM [district_tbl];
Column Count 2
Bound 1
Column Widths 0"; 1.5"

Signature
KARL DEWEY
Build a little - Test a little
> Have a form with a combo box field named "dist_code" where the user can
> select a district code; in the field next to the combo box in the form there
[quoted text clipped - 6 lines]
>
> George