Solved

Query Displays 4 copies of a record

Posted on 2011-09-07
5
381 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
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
BusyMama earned 500 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 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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.
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…

713 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