Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2005, 04:49 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Doesn't show all records from a table

I made a query from a few tables, selecting song's title from one table, it's performer from another and the lyrics author from yet another.

In the resulting query it shows only the songs for which there are at least one performer and at least one lyrics author entered, but the rest of the songs are hidden.

What should I do for it to display all the songs regardless wether the other items are entered (if not, they should appear simply blank or with a pre-defined value instead)?

Thanks!

 
Old July 6th, 2005, 10:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

try redefining the joins in the design view and see if that helps. You want all records from tblSongs and only matching records from the other two tables.


mmcdonal
 
Old July 6th, 2005, 03:06 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I tried that. But it says that "the SQL statement could not be executed because it contains ambiguous outer joins... :S

 
Old July 6th, 2005, 05:40 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

Janise,
How about trying to write the SQL using the WHERE clause, so the WHERE clause matches both the lyrics author and performer. Access gets cranky sometimes around outer joins.

HTH,
Loralee

 
Old July 7th, 2005, 04:58 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I've now rewritten the query with "Where" clause (and I don't know anything about joins, so I couldn't fix them manually anyway), and it shows the same - only the rows where the song have both the performer and aythor known.

When I view that manual query in the design view, it shows all the tables without any relationship. So, I tried to create one, and in the query the "from" clause got automatically complemented with that "join" command... And when I tried to view the datasheet, it said that the outer join is ambigous again!

 
Old July 7th, 2005, 07:16 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

This sounds like the kind of error which occurs when you try mixing the join types... can you post the sql for the query?
 
Old July 7th, 2005, 07:36 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here it is. When the query is as it is now, it doesn't give the error, but doesn't show all the songs (Dziesmas). The ambigous error appears when I set the relationships.

Thanks!

Code:
SELECT Dziesmas.Nosaukums, Dziesmas.Stils, Dziesmas.Muzika, Dzejnieki.V#257;rds, Dzejnieki.Uzv#257;rds, Dzejnieki.Grupa, Dziesmas.Vardi, Izpilditaji.Vards, Izpilditaji.Uzvards, Izpilditaji.Grupa, Dziesmas.Izpilditajs, Dziesmas.KasetesID, Dziesmas.Puse, Dziesmas.Numurs
FROM Izpilditaji, Dzejnieki, Dziesmas, [saite_Dziesmas-Dzejnieki], [saite_Dziesmas-Izpilditaji]
WHERE Dzejnieki.IDdzejnieks=[saite_Dziesmas-Dzejnieki].DzejniekaID And Izpilditaji.IDizpilditajs=[saite_Dziesmas-Izpilditaji].IzpilditajaID And Dziesmas.IDdziesma=[saite_Dziesmas-Dzejnieki].DziesmasID And Dziesmas.IDdziesma=[saite_Dziesmas-Izpilditaji].DziesmasID;
 
Old July 7th, 2005, 09:15 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

Its the relationships I wanted to look at... this is what would be causing your issues, could you post with the sql after you have set the relationships please.
 
Old July 7th, 2005, 02:53 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So, when I add a relationship where I select the radio-button "Include all records from 'Dziesmas' and only those records from 'saite_Dziesmas-Dzejnieki' where the joined fields are equal.", the query automatically changes to this:

Code:
SELECT Dziesmas.Nosaukums, Dziesmas.Stils, Dziesmas.Muzika, Dzejnieki.V#257;rds, Dzejnieki.Uzv#257;rds, Dzejnieki.Grupa, Dziesmas.Vardi, Izpilditaji.Vards, Izpilditaji.Uzvards, Izpilditaji.Grupa, Dziesmas.Izpilditajs, Dziesmas.KasetesID, Dziesmas.Puse, Dziesmas.Numurs
FROM Izpilditaji, Dzejnieki, [saite_Dziesmas-Izpilditaji], [saite_Dziesmas-Dzejnieki] RIGHT JOIN Dziesmas ON [saite_Dziesmas-Dzejnieki].DziesmasID = Dziesmas.IDdziesma
WHERE (((Dzejnieki.IDdzejnieks)=[saite_Dziesmas-Dzejnieki].[DzejniekaID]) AND ((Izpilditaji.IDizpilditajs)=[saite_Dziesmas-Izpilditaji].[IzpilditajaID]) AND ((Dziesmas.IDdziesma)=[saite_Dziesmas-Dzejnieki].[DziesmasID] And (Dziesmas.IDdziesma)=[saite_Dziesmas-Izpilditaji].[DziesmasID]));
 
Old July 26th, 2005, 08:57 AM
Authorized User
 
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you should read up on FULL JOINS. This join will display desired fields regardless if associated fields are not available. The latter will be displayed with NULL value.

"Life is a Database"





Similar Threads
Thread Thread Starter Forum Replies Last Post
show records with only values dstein4d Access VBA 1 September 2nd, 2008 04:59 PM
Show number of records Vision G Access 2 June 3rd, 2006 03:01 AM
Show ALL records from one table janise MySQL 1 September 1st, 2005 06:08 PM
Repeat region, I cannot change the 'show records' karib Dreamweaver (all versions) 3 May 6th, 2004 03:27 PM
Want to show Records on ASP Page randomly pkdev Classic ASP Databases 3 July 28th, 2003 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.