0

Anything wrong with the following query? subquery works fine but not the complete query :(

strNewSql1 = "SELECT tblEventLog.PartNumber & '_' & tblEventLog.PartNumberChgLvl FROM tblEventLog" & _
            "WHERE (tblEventLog.PartNumber & '_' & tblEventLog.PartNumberChgLvl) NOT IN " & _
            "(SELECT tblEventLog.PartNumber & '_' & tblEventLog.PartNumberChgLvl " & _
            "FROM tblEventLog " & _
            "WHERE tblEventLog.EventTypeSelected = 'pn REMOVED From Wrapper')" & _
            "AND tblEventLog.TrackingNumber = """ & tempTrackingNumber & """"

1 Answer 1

1

You are missing a space between tblEventLog and WHERE.

"SELECT tblEventLog.PartNumber & '_' & tblEventLog.PartNumberChgLvl FROM tblEventLog" & _
        "<ADD SPACE>WHERE (tblEventLog.PartNumber & '_' & tblEventLog.PartNumberChgLvl) NOT IN " & _
Sign up to request clarification or add additional context in comments.

2 Comments

And another between the end of the subquery and the final AND condition (end of the second-to-last line).
A good practice to get into when building queries this way is to start each new concatenated line with a space: " WHERE...", Makes the spaces easier to see & harder to forget, and if you get extras it doesn't hurt anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.