Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / August 2007

Tip: Looking for answers? Try searching our database.

Populating long description in form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
georgeg - 31 Aug 2007 21:25 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 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.