SQL syntax error 80040e14

Posted on 2004-11-04
Last Modified: 2013-12-25
I am getting the following syntax error (missing operator) on the following sql statement.  Any ideas?

SQLQuery = "SELECT tblClients.ClientNumber, tblClients.NachaNameControlCode, tblClientsStates.StateId, tblClientsStates.State" _
    & "FROM tblClients INNER JOIN tblClientsStates ON tblClients.ClientNumber = tblClientsStates.ClientNumber" _
    & "WHERE (((tblClientsStates.State)=NJ ));"
    rst.Open SQLQuery, cnn, adOpenKeyset, adLockOptimistic

Question by:RichFrot
    LVL 48

    Accepted Solution

    you missing a space " " just before end of each line?

    try like:

    SQLQuery = "SELECT tblClients.ClientNumber, tblClients.NachaNameControlCode, tblClientsStates.StateId, tblClientsStates.State " _
        & "FROM tblClients INNER JOIN tblClientsStates ON tblClients.ClientNumber = tblClientsStates.ClientNumber " _
        & "WHERE (((tblClientsStates.State)=NJ )); "
        rst.Open SQLQuery, cnn, adOpenKeyset, adLockOptimistic

    Works now?

    Author Comment

    Thanks -- That was the problem -- Plus I needed ' ' around NJ

    Like this
    & "WHERE (((tblClientsStates.State)='NJ' )); "
    LVL 48

    Expert Comment

    by:Ryan Chong
    ah.. damn! how can i miss that? ;-)

    you're right for above discovery, but the space is still important too, so that the recordset object recognize your sql statement.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Problem to refer to cell 8 67
    VBA Check for Character 9 62
    Validating VB6 Function 19 39
    String manipulation in Visual Basic 7 33
    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now