First off, I need to say that I am trying to teach myself the ins and outs of access so I am still very new. I use the design mode for my queries. I realize a lot of experts use the SQL view but I can't quite grasp that yet. I am taking the northwind traders example and modifying it to work for me. I am using Access 2007. Anyway, here is my query along with the error message:
SELECT [Order Details].*, IIf([Customers].[State/Province]="MI" And [Products].[Taxable]="Yes",CCur([Quantity]*[Unit Price]*(1-[Discount]))*0.06,0) AS Tax, CCur(([Quantity]*[Unit Price]*(1-[Discount]))+[Tax]) AS [Extended Price], [Order Details Status].[Status Name]
FROM Products INNER JOIN ((Customers RIGHT JOIN Orders ON Customers.ID = Orders.[Customer ID]) LEFT JOIN ([Order Details] LEFT JOIN [Order Details Status] ON [Order Details].[Status ID] = [Order Details Status].[Status ID]) ON Orders.[Order ID] = [Order Details].[Order ID]) ON Products.ID = [Order Details].[Product ID];
The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement. (Error 3258)
I kind of understand what the error is saying... Basically it doesn't know what to do first. I've tried splitting it up to no avail. What I am trying to do is say "If customer's state is Michigan (MI) AND product is Taxable" Than add tax.
Also, I am not sure I am doing it correctly because someone from Michigan could have two products (one taxable and one not taxable) how can I tell it to add tax to only the one product, not the subtotal?
Thanks for any help.
SELECT [Order Details].*, IIf([Customers].[State/Province]="MI" And [Products].[Taxable]="Yes",CCur([Quantity]*[Unit Price]*(1-[Discount]))*0.06,0) AS Tax, CCur(([Quantity]*[Unit Price]*(1-[Discount]))+[Tax]) AS [Extended Price], [Order Details Status].[Status Name]
FROM Products INNER JOIN ((Customers RIGHT JOIN Orders ON Customers.ID = Orders.[Customer ID]) LEFT JOIN ([Order Details] LEFT JOIN [Order Details Status] ON [Order Details].[Status ID] = [Order Details Status].[Status ID]) ON Orders.[Order ID] = [Order Details].[Order ID]) ON Products.ID = [Order Details].[Product ID];
The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement. (Error 3258)
I kind of understand what the error is saying... Basically it doesn't know what to do first. I've tried splitting it up to no avail. What I am trying to do is say "If customer's state is Michigan (MI) AND product is Taxable" Than add tax.
Also, I am not sure I am doing it correctly because someone from Michigan could have two products (one taxable and one not taxable) how can I tell it to add tax to only the one product, not the subtotal?
Thanks for any help.