?
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
?
177 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
Back Up Your Microsoft Windows Server®

Back up 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.

 
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 38

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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 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…
Suggested Courses

801 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