Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Query Displays 4 copies of a record

Posted on 2011-09-07
5
Medium Priority
?
395 Views
Last Modified: 2013-11-27
Great Day,

I am trying to print an invoice report for a customer who has had service performed on his/her car. the query may be more complicated than it needs to be, but I have enclosed the query and all of the associated tables. When I run the query, it appears as if numerous copies of each record are being displayed, and when I add tblParts, which I need, the query does not return any records. When you open the Query design of 'Copy Of rptInvoice Backup query' you will see that I have not added tblParts.

I need assistance with two issues relative to this query:

1. Why is it returning multiple copies of the same record?
2. Why does it not return any records when tblParts is added?

BTW, I need to add the field named 'Part' to the query from tblParts.

Thanks in advance for the assistance.

r/David
PrintInvoice.zip
0
Comment
Question by:yddadsjd95
[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
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
BusyMama earned 2000 total points
ID: 36496463
When you add the table Parts the query displays nothing because there is a defined inner join between Part and Repair Order, but the Part Type ID in the Repair Order table is null.  Since there aren't any matches, it results in nothing in the query.  Because you are using all inner joins, the query will only return records where ALL inner join criteria exist.

There are multiple copies of the records because the prices are different.  You either need to remove the columns from the query that are different (and probably put the word DISTINCT after the word SELECT in the SQL view of the query), or add up the totals and group by the remaining columns in the query if you only want one row per person.

This is a LOT of tables and joins for one query, I would suggest you rethink that to make sure you are always getting what you need.
0
 

Author Comment

by:yddadsjd95
ID: 36496520
Busy Mama, Thank you for getting back to me. You've given me a nice little assignment here, I am not quite new to Access, but I don't use it too often, so I'll work with it and get back to you.

Oh, if I need something from all of the tables, how do I get around the number of tables and joins without adding them to the Query?

r/David
0
 
LVL 7

Assisted Solution

by:BusyMama
BusyMama earned 2000 total points
ID: 36496596
If you need something from all the tables you either have to do it the way you are, or you have to split it up into several different queries.  For example, I used to do a "Make Table" query with all of the columns that I wanted from one or two tables, starting with the parent table (so just one join) - but I would also create the remaining columns that I wanted in my final result and just leave them empty.  Then I would do an "update" query for the columns that I wanted to fill in from other tables.  It was more work to set up in the long run but I reduced the risk of missing records because of inner joins.  Using update queries would just result in those fields being blank if the join was missing.  So then in your scenario, the Parts field would just be blank but I would still have the rest of the data - also would make it a little easier to troubleshoot.
0
 

Author Comment

by:yddadsjd95
ID: 36503746
BusyMama, I didn't need the partTypeID so I got rid of it, which causes values to load in the query, but I am now getting other errors. I will place this question on hold until I can clear up the othe issues.

Thanks!
0
 

Author Closing Comment

by:yddadsjd95
ID: 36510478
BusyMama, thank you for the assistance. As I advised the other say, after taking your advice, I ran into some issues unrelated to this problem. But the crew that assisted on those unrelated issues actually cleared up this one. You were sending me in the right direction though. Thanks again.
0

Featured Post

Industry Leaders: 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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

670 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