Populating long description in form

  • Thread starter georgeg via AccessMonster.com
  • Start date
G

georgeg via AccessMonster.com

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
 
C

Carl Rapson

georgeg via AccessMonster.com said:
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

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
 
G

Guest

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top