Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

SQL syntax error 80040e14

Hi,
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

Thanks,
0
RichFrot
Asked:
RichFrot
  • 2
1 Solution
 
Ryan ChongCommented:
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?
0
 
RichFrotAuthor Commented:
Thanks -- That was the problem -- Plus I needed ' ' around NJ

Like this
& "WHERE (((tblClientsStates.State)='NJ' )); "
0
 
Ryan ChongCommented:
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.

cheers
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now