Improve company productivity with a Business Account.Sign Up

x
?
Solved

Query Displays 4 copies of a record

Posted on 2011-09-07
5
Medium Priority
?
402 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 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
What to do if a split doesn't fit? Or a bunch of invoice lines must be rounded while the sum must match a total? It takes a little, but - when done - it is extremely easy to implement.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

589 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