SQL in VBA (syntax)

Derkins

Registered User.
Local time
Today, 11:40
Joined
Oct 9, 2008
Messages
17
Hey guys I just joined up a few days ago in anticipation of having some problems doing an access project for school and I'm finally stuck. Not a very complex problem I just don't know the syntax. Here is my code.

Dim stra As String
stra = "Aide"

Comn1.RowSource = "Select tblemployees.Firstname & ' ' & tblemployees.lastname " & _
"FROM tblemployees " & _
"WHERE tblEmployees.Position <> '" & stra & "'" & _
"ORDER BY tblemployees.lastname;"

This works fine but i need one more contstraint in the WHERE line and don't know how to write in an AND statement with VBA. I'v bolded the line where I need another constraint.

Thanks in advance guys
 
Derkins,

Code:
Comn1.RowSource = "Select tblemployees.Firstname & ' ' & tblemployees.lastname " & _
                  "FROM   tblemployees " & _
                  "WHERE  tblEmployees.Position <> '" & stra & "' And " & _
                  "       tblEmployees.SomeOtherField = '" & strb & "' " & _
                   "ORDER BY tblemployees.lastname;"

Wayne
 
Thanks a bunch man
 

Users who are viewing this thread

Back
Top Bottom