Results 1 to 2 of 2
  1. #1
    Pimped is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    25

    Stuck on Join Query

    Hey Guys



    I'm stuck on a Join query. I have this info I dug up from my searching:

    http://www.eggheadcafe.com/software/...on-3-tabl.aspx

    But I need to apply it to my complex query. can anyone help me?

    The normal query takes the estimate table and then takes the products query and labour query to give me a grand total list that will show everything correctly IF there are products AND labour for the estimate.

    I want to show ALL estimates whether or not they have products and labour.

    Here is my SQL as made by Access:

    Code:
    SELECT 
    Estimate.[Estimate #], 
    [Estimate Items Total].[Product Total], 
    [Estimate Items Total].[Product Discount Total], 
    [Estimate Items Total].[Estimate Items Subtotal] AS [Products Subtotal], 
    [Estimate Items Total].[Estimate Items VAT Total] AS [Products VAT Total], 
    [Estimate Labour Totals].[Labour Total], 
    [Estimate Labour Totals].[CIS Total], 
    [Estimate Labour Totals].[Labour Subtotal], 
    [Estimate Labour Totals].[Labour VAT Total], 
    (([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100 AS [Retention Amount], 
    CCur(([Estimate Items Subtotal]+[Labour subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100) AS [Retention Total],
    CCur([Estimate Items Subtotal]+[Labour Subtotal]-((([Estimate Items Subtotal]+[Labour Subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100))) AS [Estimate Subtotal], 
    CCur([Estimate Items VAT Total]+[Labour VAT Total]-(((([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)*(15/100))) AS [Estimate VAT Subtotal], 
    CCur(([Estimate Items Subtotal]+[Labour Subtotal]-((([Estimate Items Subtotal]+[Labour Subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)))+([Estimate Items VAT Total]+[Labour VAT Total]-(((([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)*(15/100)))) AS [Estimate Grand Total]
    
    
    
    FROM 
    [CIS Standard], 
    (Estimate INNER JOIN [Estimate Items Total] ON Estimate.[Estimate #] = [Estimate Items Total].[Estimate #]) INNER JOIN [Estimate Labour Totals] ON Estimate.[Estimate #] = [Estimate Labour Totals].[Estimate #]
    
    GROUP BY 
    
    Estimate.[Estimate #], 
    [Estimate Items Total].[Product Total], 
    [Estimate Items Total].[Product Discount Total], 
    [Estimate Items Total].[Estimate Items Subtotal], 
    [Estimate Items Total].[Estimate Items VAT Total], 
    [Estimate Labour Totals].[Labour Total], 
    [Estimate Labour Totals].[CIS Total], 
    [Estimate Labour Totals].[Labour Subtotal], 
    [Estimate Labour Totals].[Labour VAT Total], 
    (([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100, 
    CCur(([Estimate Items Subtotal]+[Labour subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100), 
    CCur([Estimate Items Subtotal]+[Labour Subtotal]-((([Estimate Items Subtotal]+[Labour Subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100))), 
    CCur([Estimate Items VAT Total]+[Labour VAT Total]-(((([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)*(15/100))), 
    CCur(([Estimate Items Subtotal]+[Labour Subtotal]-((([Estimate Items Subtotal]+[Labour Subtotal])*(([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)))+([Estimate Items VAT Total]+[Labour VAT Total]-(((([Retention Involved?]*[Retention Involved?])*[Estimate.Retention Amount])/100)*(15/100))));

  2. #2
    Pimped is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    25
    I sort of solved it, just took products part and made a seperate query where it was an outer join

    Took the above and made another query but added labour and did an outer join

    Then took the above and put in estimate table and voila, it worked. Now just replacing the potential nulls with Nz([xx],0) so that any nulls are handled and my forms work without "name?" or "error"

    Would still like to see if there is a simpler solution from one single query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Newbie Here & Stuck
    By FOZILD in forum Access
    Replies: 5
    Last Post: 09-24-2009, 08:26 AM
  2. How does Access guess join field in query?
    By bar tomas in forum Database Design
    Replies: 1
    Last Post: 05-27-2009, 05:56 PM
  3. Newb stuck on Normalization
    By dave_wilford in forum Database Design
    Replies: 6
    Last Post: 05-19-2008, 02:39 PM
  4. Replies: 1
    Last Post: 09-19-2006, 11:07 AM
  5. Dynamic Query Outer Join Problem
    By mjack003 in forum Queries
    Replies: 0
    Last Post: 07-21-2006, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums