Microsoft Jet database engine error – does not recognize ‘[|]’ as a valid field name or expression

Question : Microsoft Jet database engine error – does not recognize ‘[|]’ as a valid field name or expression

I am getting the error message from Microsoft Query:
The Microsoft Jet database engine does not recognize ‘[|]’ as a valid field name or expression.

What I am attempting to do is refresh to Excel the data returned from this query.  I do this often without problems.

This is SQL Code:
SELECT [815-3 Stock].Itemkey
FROM (((([815-3 Stock]
LEFT JOIN [815-2 AverageWeeklyRMUsage] ON [815-3 Stock].Itemkey = [815-2 AverageWeeklyRMUsage].ItemkeyReq)
LEFT JOIN [815-4 OnOrder] ON [815-3 Stock].Itemkey = [815-4 OnOrder].Itemkey)
LEFT JOIN [250-1a Earliest Purchase Order] ON [815-3 Stock].Itemkey = [250-1a Earliest Purchase Order].Itemkey)
LEFT JOIN [663-1A Itemkey Invoicing – Annual] ON [815-3 Stock].Itemkey = [663-1A Itemkey Invoicing – Annual].Itemkey)
LEFT JOIN [663-1A Itemkey Invoice Qty by Month] ON [815-3 Stock].Itemkey = [663-1A Itemkey Invoice Qty by Month].Item
WHERE ((([815-3 Stock].Itemkey)=”CNONSOL233″));

It doesn’t matter whether I change the “LEFT” above to “INNER”, the query still doesn’t work.

All MSAccess queries execute without problem in MS Access 2000
In Microsoft Query I am able to open all Access queries individually but not the joined query
I am not 100% sure what the character enclosed in [ is but it looks like the straight down slash

I’ve been working with this for entire 1 1/2 days … have reinstalled office and everything to no avail.

Any help much appreciated


 

Solution: Microsoft Jet database engine error – does not recognize ‘[|]’ as a valid field name or expression

 

 > doing without using the UNION command as MS Query doesn’t seem to like it

UNION queries can be processed in MS Query.  But, as with any UNION query, some rules have to be followed like:

1) The number and the order of the columns must be identical
2) The data types must be compatible.

So, using the Northwind.mdb database, this works fine in MS Query:

SELECT c.CustomerID, c.CompanyName, c.ContactName, c.ContactTitle, c.Address, c.City, c.Region, c.PostalCode,
c.Country  AS [NewCountry], c.Phone, c.Fax
FROM `C:Northwind`.Customers c
WHERE c.Country = ‘USA’

UNION ALL

SELECT c.CustomerID, c.CompanyName, c.ContactName, c.ContactTitle, c.Address, c.City, c.Region, c.PostalCode,
c.Country AS [NewCountry], c.Phone, c.Fax
FROM `C:Northwind`.Customers c
WHERE c.Country = ‘UK’

> completely removed the WHERE

Maybe, but I still see one here using double quotes:

WHERE (((INBMBOM.Lintyp)=”I”) AND ((INMAST.Itemtyp)=”F”));

Assuming that the data are the same for the field pairs of:

NMAST.Itemkey &  [810-4 Itemkey Recipe Usage].SelectedItemkey
INBMBOM.Bomitemkey & [810-4 Itemkey Recipe Usage].Itemkey
INBMBOM.Bomqty & [810-4 Itemkey Recipe Usage].ItemkeyReq

then your SQL statement could be something like this:

SELECT INMAST.Itemkey AS [SelectedItemkey], INBMBOM.Bomitemkey AS [ItemkeyReq], INBMBOM.Bomqty AS [ItemkeyQtyReq]
FROM INMAST INNER JOIN INBMBOM ON INMAST.Itemkey = INBMBOM.Itemkey
WHERE (((INBMBOM.Lintyp)=’I’) AND ((INMAST.Itemtyp)=’F’))

UNION ALL

SELECT iru.SelectedItemkey, iru.Itemkey, iru.ItemkeyReq
FROM [810-4 Itemkey Recipe Usage] iru