Solved

MS Access lookup values in query / form

Posted on 2014-03-11
5
3,103 Views
Last Modified: 2014-03-11
Haven't used MS Access for a while and can't figure this out:

I have a products table that has two columns - "ProductID" (pk) and "Product"

I have an Orders table that contains a lookup column "Product(s)" that uses the rowsource "SELECT Products.ProductID, Products.Product FROM Products;" its Bound col 1, column count 2 and col widths 0;2.54cm

This all works fine.

I then have created a query that filters the order table by customerID.

This works fine - when I view the query I see required columns, including the "Product(s)" lookup column that shows a list of the product names.

As an example in the Product(s) field I will see "Design, Marketing, Brochure"

However, when I try to use this query in a form (continuous form view) it only shows the productID's in the lookup box not the Product(names) I see in the query?

i.e. it now shows "1,3,4"

How can I make it so that the "Product" column (product names) show and not the ProductID field?

Many thanks,

Sam
0
Comment
Question by:SamB
  • 2
  • 2
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
create a query, using the Orders table with a join in Products table field ProductID
choose all the fields that you need from the Orders table AND to show the Product description, include in your column the Product field from the Products table.


select Orders.*, Products.Product
From Orders Inner join Products on Orders.ProductID=Products.ProductID
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
Check the control in the form.  It should be a combo and have the same settings that you set for the lookup.

There's not need to include the product table in the forms base query unless you don't want to use a combo control for some reason.

Jim.
0
 
LVL 1

Author Comment

by:SamB
Comment Utility
Can't get either solution to work.

I've attached the demo database .....

You'll see the query shows the info I need but the form reverts back to ID's only ?

Many thanks,

Sam
Database.accdb
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
Comment Utility
Sam,

 Doesn't look like you tried either?

  The form currently has a text box, not a combo box and it's bound to "Product(s)" (which BTW is a bad field name - stay away from any type of special characters in field names).

 You either need to change the control to a combo box, in which case you will be able to set things just as you did for the lookup properties

 or

 you need to do what Ray suggested and include the products table and the description field in the forms underlying query.

If the intent is to add/edit with this form, then the combo box is probably the best, but you still can do it either way.   If you follow Ray's suggestion, you'll need two text controls; one for the product key and then one to display the description.

Jim.
0
 
LVL 1

Author Closing Comment

by:SamB
Comment Utility
Thanks Jim.

I had changed to a combobox but didn't work - on further investigation I had left the 'Column Count' property at '1' and not updated to '2'. Once did this your solution worked.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
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…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

763 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

6 Experts available now in Live!

Get 1:1 Help Now