SQL Where statement

S

Song Su

This works

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud ORDER BY qrysapbud.Fund"


But this does not. Is there any mistakes in that single/double quote at the
end? qrysapbud.type is character type.

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud ORDER BY qrysapbud.Fund WHERE funddesc.type = 'U'"
 
J

John W. Vinson

This works

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud ORDER BY qrysapbud.Fund"


But this does not. Is there any mistakes in that single/double quote at the
end? qrysapbud.type is character type.

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud ORDER BY qrysapbud.Fund WHERE funddesc.type = 'U'"

It doesn't for the same reason this sentence sounds strange work.

The WHERE clause must come before the ORDER BY clause.

Try

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud WHERE funddesc.type = 'U' ORDER BY qrysapbud.Fund;"
 
S

Song Su

Got it. It works. Thanks a lot.

John W. Vinson said:
It doesn't for the same reason this sentence sounds strange work.

The WHERE clause must come before the ORDER BY clause.

Try

Me.cboFund.RowSource = "SELECT DISTINCT qrysapbud.Fund,
qrysapbud.Funddesc.desc, qrysapbud.type " & _
"FROM qrysapbud WHERE funddesc.type = 'U' ORDER BY qrysapbud.Fund;"
 
Top