Solved

MS Access lookup values in query / form

Posted on 2014-03-11
5
3,449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39920357
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
ID: 39920388
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
ID: 39920463
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
ID: 39920827
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
ID: 39920991
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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