Solved

drop down field

Posted on 2011-03-06
8
418 Views
Last Modified: 2012-05-11
I have 2 tables with a one to many relationship in Access 2007
With form entry I want one of the tables to have adrop down list of values to select from the other table of same field.

How do i set up the form field to link to anthor table and display values to select from?
0
Comment
Question by:jagguy
8 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
Comment Utility
Open the table in design view, select the field that you want to have the drop down.
Then click Lookup tab. Select Combo box in Display Control.

RowSource type: Table/Query
Row Source: The name of your table.


When you put that field into the entry form, it will create a combo box that looking up the data of the table you specify.


sincerely,
Ed
0
 

Author Comment

by:jagguy
Comment Utility
ok i get that.

what i also need is when i select a value from drop down box , I want another associated  field to display.

For example I might select Item ID from a combo box and I want the Item name to also appear somewhere whenever i select an item ID (the ItemID and name is defined in another table of course)
0
 
LVL 19

Expert Comment

by:MINDSUPERB
Comment Utility
You may try to use this vba:

At the after update event of the combo box

Me.YourFieldName = DLookUp("YourItemName","tblYourTableName","[ItemID] = & Nz(Me.cboNameOfCombo,0) ")

Ed
0
 
LVL 19

Expert Comment

by:MINDSUPERB
Comment Utility

Try to use this instead:

Me.ItemName = DLookUp("ItemName",YourTable","[ItemID] = Nz(cboName,0)")

ItemName = the fieldname of Item Name
YourTable = name of your table where ItemID and ItemName are found
ItemID = the ItemID field
cboName = the name of your combo box

Ed
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:jagguy
Comment Utility
i dont want VBA code so is there another way i could do it?
0
 
LVL 19

Expert Comment

by:MINDSUPERB
Comment Utility
You can create a subform and set the Link Master Fields and Link Child Fields Properties to ID and ItemID.

But, I suggest to use the VBA and just invest some of your time on it. It is always nice to learn something new.

Ed
0
 
LVL 2

Expert Comment

by:wobblynut
Comment Utility
On the form control  where the id dropdown is (say called cmbID)
set the rowsource to SELECT table2.ID, table2.name FROM table2;
set bound column =1
column count=2
column widths 2.5,0

Set the control source on the form's control where you want the name to appear to =[cmbID].[column](1)

0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
Comment Utility
Put the other field you want to display in the combo box's row source, and then use something like this as the control source of an unbound and locked textbox:

=[cboSelect].Column(2)

Column numbering is zero-based, so this refers to the 3rd column.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now