Solved

Query Displays 4 copies of a record

Posted on 2011-09-07
5
344 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

746 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

11 Experts available now in Live!

Get 1:1 Help Now