Solved

drop down field

Posted on 2011-03-06
8
422 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
ID: 35045949
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
ID: 35045959
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
ID: 35045973
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
ID: 35046029

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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

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

Expert Comment

by:MINDSUPERB
ID: 35046064
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
ID: 35046079
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
ID: 35047146
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete duplicate Data from Access 2016 Query 8 41
Print focus keeps focusing to the caller form 3 25
DSum for Access 6 43
how to link subforms ms/access VBA 6 23
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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.

932 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

10 Experts available now in Live!

Get 1:1 Help Now