New Post on Syntax Help For Ken

G

Guest

This is the code that Ken gave me previously and it works great. Problem is
I have added a field, from another table, and don't know how to address the
INNER Join portion of the syntax

'*******This code works OK except I did not put in the UserFFText1 in this
SQL Statement
strFilter = "SELECT tblAccounts.AccountNumber, " & _
"tblAccounts.AccountName, tblAccounts.City, tblAccounts.State," & _
"tblAccounts.PostalCode , tblAccounts.AccountType, " & _
"tblAccounts.PrimaryPhoneNumberFormatted, " & _
"tblAccounts.PrimaryFaxNumberFormatted, " & _
"tblAccounts.PrimaryEmailAddress, tblAccounts.URL1 " & _
"FROM tblAccounts WHERE AccountName Like '" & _
strFilterName & "%" & "' AND AccountType<>'Prospect' " & _
"AND AccountType<>'Customer'"
'**** END OF WORKING CODE ********

I am trying to get this code to exactly the same as above but with these
fields.

I understand that the line continuation is probably wrong here but this is
the way I have it in my code window in Access.

strFilter = "SELECT tblAccounts.AccountNumber, tblAccounts.AccountName,
tblAccounts.City, tblAccounts.State, " & _
"tblAccounts.PostalCode, tblAccounts.AccountType,
tblAccounts.PrimaryPhoneNumber, " & _
"tblAccounts.PrimaryFaxNumber, tblCustomAccount.UserFFText1 " & _
"FROM tblAccounts INNER JOIN tblCustomAccount ON
tblAccounts.AccountNumber = tblCustomAccount.AccountNumber, & _
WHERE AccountName Like '" & _
strFilterName & "%" & "' AND AccountType<>'Prospect' " & _
"AND AccountType<>'Customer'"

Thanks again for any assistance you may be able to give.
 
K

Ken Snell [MVP]

This line
"FROM tblAccounts INNER JOIN tblCustomAccount ON
tblAccounts.AccountNumber = tblCustomAccount.AccountNumber, & _

needs to be this line instead:
"FROM tblAccounts INNER JOIN tblCustomAccount ON
tblAccounts.AccountNumber = tblCustomAccount.AccountNumber, " & _
 
G

Guest

Ken I am getting an incorrect syntax new keyword WHERE wth the following but
it complies OK ?

strFilter = "SELECT tblAccounts.AccountNumber, " & _
"tblAccounts.AccountName, tblAccounts.City, tblAccounts.State, " & _
"tblAccounts.PostalCode, tblAccounts.AccountType, " & _
"tblAccounts.PrimaryPhoneNumber, tblAccounts.PrimaryFaxNumber,
tblCustomAccount.UserFFText1 " & _
"FROM tblAccounts INNER JOIN tblCustomAccount ON " & _
"tblAccounts.AccountNumber = tblCustomAccount.AccountNumber," & _
"WHERE AccountName Like '" & _
strFilterName & "%" & "' AND AccountType<>'Prospect' " & _
"AND AccountType<>'Customer'"

Thanks
 
K

Ken Snell [MVP]

In the code line above the one that contains the WHERE word, there is a
comma at the end that should be replaced with a space:

strFilter = "SELECT tblAccounts.AccountNumber, " & _
"tblAccounts.AccountName, tblAccounts.City, tblAccounts.State, " & _
"tblAccounts.PostalCode, tblAccounts.AccountType, " & _
"tblAccounts.PrimaryPhoneNumber, tblAccounts.PrimaryFaxNumber,
tblCustomAccount.UserFFText1 " & _
"FROM tblAccounts INNER JOIN tblCustomAccount ON " & _
"tblAccounts.AccountNumber = tblCustomAccount.AccountNumber " & _
"WHERE AccountName Like '" & _
strFilterName & "%" & "' AND AccountType<>'Prospect' " & _
"AND AccountType<>'Customer'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with SQL syntax please 1
Syntax Help 5
Adding syntax to SQL Statement 1

Top