Adding syntax to SQL Statement

G

Guest

This code works fine for filtering my grid and returning the proper Customer
records. I would like to add Prospect to the criteria but am having trouble
with the syntax to accomplish this

Private Sub txtAccountName_KeyUp(KeyCode As Integer, Shift As Integer)
Dim strFilter As String
Dim strFilterName
This code works fine and pulls the correct records if AccountType =
Customer. I would like to also pull records where AccountType = Prospects
and am having trouble with the sysntax.

strFilterName = Me.txtAccountName.Text

strFilter = "SELECT tblAccounts.AccountNumber, " & _
"tblAccounts.AccountName , tblAccounts.Address1, tblAccounts.Address2, " & _
"tblAccounts.City, tblAccounts.State, tblAccounts.PostalCode,
tblAccounts.AccountType " & _
"FROM tblAccounts " & _
"WHERE AccountName Like '" & _
strFilterName & "%" & "' AND AccountType ='Customer'"

I have tried
AND AccountType = 'Prospect'"
OR AccountType = 'Prospect'"

I could use help with the proper syntax to add the second criteria.

Thanks in advance.
 
S

Steve Schapel

Cvegas,

Your "OR" clause should work, although I would enclose them in
parentheses, like this...
... AND (AccountType ='Customer' OR AccountType ='Prospect')"
 

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
New Post on Syntax Help For Ken 3
Syntax Help 5

Top