More Than SQL Query

waq963

Registered User.
Local time
Today, 07:14
Joined
Jan 27, 2009
Messages
84
Hi, Basically i would like to know the correct syntax for a more thanand equal to query. Here is what i have so far:
Private Sub cboTest_Enter()
Dim strSQL As String
strSQL = "SELECT tblAnsweredQ.ID, tblAnsweredQ.Brand "
strSQL = strSQL + "FROM tblAnsweredQ, tblProducts "
strSQL = strSQL + "WHERE tblAnsweredQ.ID = tblProducts.[ID] "
strSQL = strSQL + "AND tblAnsweredQ.ID = >='UK2';"
cboTest.RowSource = strSQL
End Sub
Access says that there are syntax errors. Can anyone help please? Thanks.
 
Hi,

There are two things wring

1) strSQL = strSQL + "WHERE tblAnsweredQ.ID = tblProducts.[ID] "
If you require the value from tblProducts.[ID] then the corrected way to substitute is
strSQL = strSQL + "WHERE tblAnsweredQ.ID = " & tblProducts.[ID] & " "
2) strSQL = strSQL + "AND tblAnsweredQ.ID = >='UK2';"
should read
Error noted here strSQL = strSQL + "AND (tblAnsweredQ.ID = 'UK2' OR tblAnsweredQ.ID >= 'UK2' (;"

Should be
strSQL = strSQL + "AND (tblAnsweredQ.ID >= 'UK2');"
 
Last edited:
Cheers Mate worked a treat
 
1) This is not access SQL, cause that would be using Inner join to join the tables.

2) tblAnsweredQ.ID = 'UK2' OR tblAnsweredQ.ID >= 'UK2' ???

>= should be enough?? The = is not needed

3)
For "proper" and "readable" sql in you code use...
strSQL = ""
strSQL = strSQL + " SELECT ... "
strSQL = strSQL + " FROM ... "

Also note the "extra" space before the Select and From, this is to prevent any problems from popping up because you forgot the space on the end. Start of the line is easy to check, end of the line(s) a lot harder.
 

Users who are viewing this thread

Back
Top Bottom