Solved

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

Posted on 2015-01-06
6
154 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
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 119

Accepted Solution

by:
Rey Obrero earned 350 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 119

Expert Comment

by:Rey Obrero
ID: 40534194
upload a copy of your db
0
What Security Threats Are You Missing?

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.

 
LVL 26

Assisted Solution

by:Nick67
Nick67 earned 150 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 34

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

What Security Threats Are You Missing?

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.

Join & Write a Comment

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now