Re: inner join syntax error
IMO 'SYSTEM' is a problem name or a reserved word, try using brackets around it []
Also, visit --> http://allenbrowne.com/AppIssueBadWord.html#S
JG
Re: inner join syntax error
Still having the same problem, even if changing the table name for system. e.g. (SYSTEM_ROLE)
It's odd, since the exact syntax is working fine inside Access itself. Yet from my VB6 program, it is throwing the inner join syntax error.
Re: inner join syntax error
Put a space before each double-quote. I don't know if you put it on multiple lines for demonstration purposes on this board or it's all on one line in code but the way you have it written, would translate into
SELECT SYSTEM.EMAILFROM CUSTOMER INNER JOIN SYSTEMON CUSTOMER.ID = SYSTEM.IDWHERE (((CUSTOMER.STATE) = '" & mySt & "')) " the ones in bold are missing spaces.
Try
Code:
strSQL = "SELECT SYSTEM.EMAIL " & _
"FROM CUSTOMER INNER JOIN SYSTEM " & _
"ON CUSTOMER.ID = SYSTEM.ID " & _
"WHERE (((CUSTOMER.STATE) = '" & mySt & "')) "
Re: inner join syntax error
I would take it one step further, and "stretch" out the string to multiple lines
Code:
strSQL = "SELECT SYSTEM.EMAIL "
strSQL = strSQL & "FROM CUSTOMER "
strSQL = strSQL & "INNER JOIN SYSTEM ON CUSTOMER.ID = SYSTEM.ID "
strSQL = strSQL & "WHERE (((CUSTOMER.STATE) = '" & mySt & "')) "
Now it is a bit easier to read. Those spaces mentioned are EXTREMELY important.
Now I'll take it two steps further and say you really shouldn't be using Inline SQL anyway. Look into parametized queries.
Re: inner join syntax error
Quote:
Originally Posted by
Hack
I would take it one step further, and "stretch" out the string to multiple lines
Code:
strSQL = "SELECT SYSTEM.EMAIL "
strSQL = strSQL & "FROM CUSTOMER "
strSQL = strSQL & "INNER JOIN SYSTEM ON CUSTOMER.ID = SYSTEM.ID "
strSQL = strSQL & "WHERE (((CUSTOMER.STATE) = '" & mySt & "')) "
Now it is a bit easier to read. Those spaces mentioned are EXTREMELY important.
Now I'll take it two steps further and say you really shouldn't be using Inline SQL anyway. Look into parametized queries.
This was the problem.
mySt variable needs to contain double quotes around it inside the sql string. Code above ends up sending the following in the string:
Code:
WHERE (((CUSTOMER.STATE) = 'GA' ))
I'm now reading up on the parametized queries from threads on the forums here.
Still curious though, how would I include the double quotes in that statement using my current format. '"" mySt ""' and " ' " turns it into a comment.
I definitely see what using parameter based queries would be helpful though!
Re: inner join syntax error
You wouldn't use quotes.
You would use the @ sign and variable or control name
Re: inner join syntax error
Quote:
Originally Posted by
Hack
You wouldn't use quotes.
You would use the @ sign and variable or control name
Thanks.
Are there any other good resources to read here on the parameter queries.
I've found a few with great examples.
http://www.vbforums.com/showthread.php?t=548787
http://www.vbforums.com/showthread.php?t=381391
Always picky on outside sources found via google.