Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL syntax error 2

Status
Not open for further replies.

Russ1005

Programmer
Dec 13, 2004
96
US
Any idea why I'm getting a syntax error on this statement?

Thanks for you help,

-Russ


Forms!casedatabaseform![Child215]!Model.RowSource = "SELECT edge_model_no, lowes_sku, description, edge_item_number,AVG_PRICE " & _
"FROM ITEM_MASTER_VIEW " & _
"WHERE [CUSTOMER_NUMBER] = " & "'N" & Forms!casedatabaseform!Account.Value " & _
"union " & _
"SELECT edge_model_no, lowes_sku, description, edge_item_number,AVG_PRICE " & _
"FROM ITEM_MASTER_VIEW " & _
"WHERE (lowes_sku >= 99900 and lowes_sku < 100000)"
 
You have an opening single quote here:
Code:
& "[COLOR=red][b]'[/b][/color]N" & Forms!casedatabaseform!Account.Value " & _
    "union " & _
but no closing quote.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Replace this:
"WHERE [CUSTOMER_NUMBER] = " & "'N" & Forms!casedatabaseform!Account.Value " & _
By this:
"WHERE [CUSTOMER_NUMBER] = " & "'N" & Forms!casedatabaseform!Account.Value & "'" & _
Or this:
"WHERE [CUSTOMER_NUMBER] = '" & Forms!casedatabaseform!Account.Value & "'" & _

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for you quick response.

Ok, I'm past the syntax error but the output is not what is expected.

Only the right side of the union is showing up in the result set.

Forms!casedatabaseform![Child215]!Model.RowSource = "SELECT edge_model_no, lowes_sku, description, edge_item_number,AVG_PRICE " & _
"FROM ITEM_MASTER_VIEW " & _
"WHERE [CUSTOMER_NUMBER] = " & "'N" & Forms!casedatabaseform!Account.Value & "' " & _
"union " & _
"SELECT edge_model_no, lowes_sku, description, edge_item_number,AVG_PRICE " & _
"FROM ITEM_MASTER_VIEW " & _
"WHERE (lowes_sku >= 99900 and lowes_sku < 100000)
 
And this ?
"WHERE [CUSTOMER_NUMBER] = '" & Forms!casedatabaseform!Account.Value & "' " & _

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yay! That did it. Thanks for your help guys.

I thought I needed the "'N" because the database is SQL Server.

-Russ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top