Syntax Error (missing operator) in query expression (1 Viewer)

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
Hi all, I get the error when i run my query and i have check that i do not miss out any open or close bracket. How can i fix this?

Code:
SELECT FabricPOqry*
From FabricPOqry LEFT JOIN MainTable ON (FabricPOqry.StyleNO = MainTable.StyleNo) AND (FabricPOqry.[GL Lot] = MainTable.GLA) AND (FabricPOqry.PO = MainTable.GLGPO) AND (FabricPOqry.Line = MainTable.Line) AND (FabricPOqry.[Our Qty] = MainTable.Lbs) AND (FabricPOqry.[Supplier Qty]  = MainTable.Yds) AND 
(FabricPOqry.GSMBeforeWash = MainTable.FinishedGoods) AND (FabricPOqry.GMSPerSqYD = MainTable.GSMPerSqYd)
WHERE (((FabricPOqry.StyleNO) is Null) AND ((FabricPOqry.[GL Lot]) is  Null) AND ((FabricPOqry.PO) is Null) AND ((FabricPOqry.Line) is Null) AND ((FabricPOqry.[Our Qty]) is Null) AND ((FabricPOqry.[Supplier Qty]) is Null) AND ((FabricPOqry.GSMBeforeWash) is Null) AND ((FabricPOqry.GMSPerSqYD) is Null));
 

JHB

Have been here a while
Local time
Today, 13:25
Joined
Jun 17, 2012
Messages
7,732
This one is the problem FabricPOqry* you're missing the dot between the table name and the star!
Correct is FabricPOqry.*
 

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
This one is the problem FabricPOqry* you're missing the dot between the table name and the star!
Correct is FabricPOqry.*

Thanks! After i have added in the . and run again. It prompt me another error"Syntax error (missing operator) in query expression".
 

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
This one is the problem FabricPOqry* you're missing the dot between the table name and the star!
Correct is FabricPOqry.*

Thanks! I have fixed the error. However, when i run the query, no records is shown on the query
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:25
Joined
Feb 28, 2001
Messages
27,172
That query has to have a LOT of things going for it in order to return any records.

FIRST, you need to find eight of your FabricPOqry object (whatever it is) with nulls. But SECOND, you need to find records where eight OTHER fields exactly match some record in the MainTable object (which I assume is a table). That is 16 exacting criteria.

In order to partly debug this, I might run the query without the WHERE clause to see if your problem is an over-restrictive JOIN. The WHERE filters will return nothing in either of two cases, you see: No records matched the WHERE clause or no records were found for the eight-way JOIN.

If you do this without the WHERE clause and STILL get nothing, your problem is that the JOIN over-specifies the selection criteria.
 

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
That query has to have a LOT of things going for it in order to return any records.

FIRST, you need to find eight of your FabricPOqry object (whatever it is) with nulls. But SECOND, you need to find records where eight OTHER fields exactly match some record in the MainTable object (which I assume is a table). That is 16 exacting criteria.

In order to partly debug this, I might run the query without the WHERE clause to see if your problem is an over-restrictive JOIN. The WHERE filters will return nothing in either of two cases, you see: No records matched the WHERE clause or no records were found for the eight-way JOIN.

If you do this without the WHERE clause and STILL get nothing, your problem is that the JOIN over-specifies the selection criteria.

The query returned me results after i remove the where clause. How do i move on from here?
 

isladogs

MVP / VIP
Local time
Today, 12:25
Joined
Jan 14, 2017
Messages
18,216
Try adding them back one at a time so you can see which criterion or criteria cause your issue

Also consider whether any of these could be done using OR rather than AND
 
Last edited:

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
Ty adding them back one at a time so you can see which criterion or criteria cause your issue

Also consider whether any of these could be done using OR rather than AND

Thank you! I have solved it!
 

isladogs

MVP / VIP
Local time
Today, 12:25
Joined
Jan 14, 2017
Messages
18,216
For the benefit of others who may view this thread in future, please explain what the solution was
 

luzz

Registered User.
Local time
Today, 04:25
Joined
Aug 23, 2017
Messages
346
For the benefit of others who may view this thread in future, please explain what the solution was

The purpose of me doing this query is to build an unmatched query based on multiple fields. After researching, i found out that i can actually use the unmatched wizard in Access to help me do that. If i want to have other join criteria i can simply type in my own criteria in the unmatched query SQL.
 

Users who are viewing this thread

Top Bottom