Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I connect 2 fields in one table to a single field in another table?

Posted on 2015-01-06
6
Medium Priority
?
179 Views
Last Modified: 2015-01-06
I think I'm having a brain cramp on this.  I have a single query that I am trying to design for some transactions that I am trying to report on. Initially, the query included a field from my main table that showed a code for the "From Location" and another field for the "To Location".  I just added another table that has all of the location codes in a single column, followed by the Names of the locations in another field.

I want to design my query to tie in the From Location Name, and the To Location Name.  In design query, I have 2 fields from my main table tied to a single field in the second table, but I don't think that will work and am not sure what to do.
0
Comment
Question by:Dominator1025
[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
6 Comments
 

Author Comment

by:Dominator1025
ID: 40534172
To be more clear, the From and To Location codes in the main table are both in the same record, which then needs to be tied to multiple records in the second table that relates the codes to the names.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1400 total points
ID: 40534193
add another second table to your query grid
connect From to the first secondtable
connect To to the second secondtable
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40534194
upload a copy of your db
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Assisted Solution

by:Nick67
Nick67 earned 600 total points
ID: 40534199
It is not intuitive, but you can add a table to a query MORE THAN ONCE.
Why?
For exactly this situation.
So add the table twice
First, it'll be tblLocation, and when you add it again it'll be tblLocation_1
Get rid of any pre-existing joins the Query Editor creates
Then create the join from tblLocation to the field that is the To location ID
Then create the join from tblLocation_1 to the field that is the from Location ID

You're then in business!
0
 

Author Closing Comment

by:Dominator1025
ID: 40534345
Thanks guys. I wasn't sure exactly what Rey meant, but then Nick's answer made it click and drove it home for me.  I appreciate it!
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 40534353
You will also want to alias the column names you select from tblLocation.  Assuming the name of the column you want to select is LocationName then for each of the two uses:

FromLocationName:tblLocation.LocationName

ToLocationName:tblLocation_1.LocationName

If you don't do this, Access will give them names you won't like because EVERY column in the query MUST have a UNIQUE name.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

636 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