Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 21st, 2004, 11:12 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Joins in Multiple Table Search query

Good day all..

I am trying to create a simple Search form in Access where a user can select a desired record and query multiple tables using the inputs.

I would like them to be able to query Retailers, Distributors and Products.

The 6 tables are linked as follows:
Although some of these tables are not included in the query, they are required to ensure relationships.

Retailers -- Uses (RetailerID,DistributorID) -- Distributors
Retailers -- Orders (RetailerID,ProductID) -- Products

All retailers have at least one distributor BUT a retailer may or may not have ordered any products.

I have created my form but the query linked to the form is having some trouble. It is only selecting those records that have ordered products. For example, if I query a retailer name only and it does not have any ordered products, it will not display. Is there a problem with the table joins? The SQL for the query is displayed here:


Code:

SELECT DISTINCT Retailers.RetailerID, Retailers.RetailerName, Retailers.Address, Retailers.City, Retailers.Province, Retailers.PostalCode, Retailers.AreaCode, Retailers.PhoneNumber, Retailers.FaxNumber, Retailers.ContactName, Retailers.EmailFROM (Retailers INNER JOIN (Products INNER JOIN Orders ON Products.ProductID=Orders.ProductID) ON Retailers.RetailerID=Orders.RetailerID) INNER JOIN (Distributor INNER JOIN Uses ON Distributor.DistributorID=Uses.DistributorID) ON Retailers.RetailerID=Uses.RetailerIDWHERE (((Retailers.RetailerName) Like forms!frmMultiFieldSearch!txtRetailerTwo) And ((Distributor.DistributorName) Like forms!frmMultiFieldSearch!txtDistTwo) And ((Products.ProductName) Like forms!frmMultiFieldSearch!txtProductTwo));

Is it possible for me to do this the way I have set it up?

I have tried using a LEFT JOIN between Retailers and Orders but I get an ambiguous join error. I have tried other joins as well but either I get that error or it does the same thing by only displaying those records that have ordered products.

Would creating muliple queries and using a union help?

Please let me know if you need more info!
Thanks in advance!

Reply With Quote
  #2 (permalink)  
Old September 21st, 2004, 02:50 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Pookster!
I 've tried opening the Northwind db and changing the join type from Customer tb with Orders tb to select all records from Customers and only those from Orders that are equal. I've opened the Orders Form in data entry mode and i've selected a Customer with no orders and it worked OK.
Hope this will help u.
Regards Penta.

Reply With Quote
  #3 (permalink)  
Old September 22nd, 2004, 08:37 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It could just be that there is a problem because it is accessing data from more than 2 tables.

I think this query is way over my head! :(

Reply With Quote
  #4 (permalink)  
Old September 23rd, 2004, 09:33 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solved it Using the Nz function

(Nz(Products.ProductName) Like forms!frmMultiFieldSearch!txtProductTwo));

Reply With Quote
  #5 (permalink)  
Old September 23rd, 2004, 03:04 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Good u have solved it!
By the way i came on reading Litwin & Getz & Gunderloy, that "a table with an
arrow pointing toward it can't also be connected to either a line with no arrow
or another arrow pointing toward it".
Regards P.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Joins for multiple tables Jinn SQL Server 2000 2 November 5th, 2006 11:39 PM
Multiple table Query-HELP Kathryn SQL Language 1 March 22nd, 2005 10:57 AM
Multiple Inner Joins msmagied Classic ASP Databases 0 October 6th, 2004 05:11 PM
multiple self joins and sum juan@jbstech.net SQL Language 3 May 25th, 2004 06:03 PM
Multiple Table Query Problem mikericc Access 3 February 16th, 2004 12:21 PM



All times are GMT -4. The time now is 05:11 PM.


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