Link to home
Start Free TrialLog in
Avatar of sltan32
sltan32

asked on

Access SQL query for Crosstab query not working

Hi, I'm trying to create a crosstab query in Access 2007 and I'm encountering the following error message after setting up the join property.

The error message is "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 that first join and then include that query in your SQL statement."

I'm also enclosing the SQL query for reference:

TRANSFORM Sum(MPlanShipment.NoOfPcs) AS SumOfNoOfPcs
SELECT MPlanShipment.ShipmentCode, tblForwarder.ForwarderName
FROM tblForwarder INNER JOIN (Tbl_Next7days LEFT JOIN MPlanShipment ON Tbl_Next7days.Cur_Date = MPlanShipment.ContTruckingdate) ON tblForwarder.ForwarderID = MPlanShipment.Forwarder
GROUP BY MPlanShipment.ShipmentCode, tblForwarder.ForwarderName
PIVOT Tbl_Next7days.Cur_Date_WkdayName;

Appreciate if you can advise how to amend the SQL query in order run the report.  Thanks you very much.
Access-SQL-Setup.JPG
SQL-Error-message.JPG
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Try using:

    LEFT JOIN (Tbl_Next7days LEFT JOIN

/gustav
ASKER CERTIFIED SOLUTION
Avatar of sltan32
sltan32

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was mean to replace:

    INNER JOIN (Tbl_Next7days LEFT JOIN

Or just double-click the inner join in the designer and change the join to a left join.

If it still doesn't work (I don't have your tables), move the inner-joined tables to a subquery.

/gustav
Avatar of sltan32
sltan32

ASKER

problem solved as it is caused by another join in the statement that is not configured properly
Avatar of sltan32

ASKER

Found out the reason that causes the SQL not to work as it is caused by another join not properly configured.