error in code

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

I have a perfectly normal query giving the right results. but when i copy it
and try to use it as sql i get red letters.May be i will have to change the
commas or something ?

strsql = " SELECT products1.Productid, DLookUp("grade","products","productid
= " & [productid]) AS Expr1, products1.items4, products1.branch4 FROM
products1 WHERE (((products1.items4)>0))"
 
M

Marshall Barton

peljo said:
I have a perfectly normal query giving the right results. but when i copy it
and try to use it as sql i get red letters.May be i will have to change the
commas or something ?

strsql = " SELECT products1.Productid, DLookUp("grade","products","productid
= " & [productid]) AS Expr1, products1.items4, products1.branch4 FROM
products1 WHERE (((products1.items4)>0))"


The interior quotes are wrong and I can't tell if it was all
on one line or you did not use proper line continuations.

I would write it more like:

trsql = "SELECT Productid, " _
& "DLookUp(""grade"",""products"", " _
& """productid = " & productid & """") AS Expr1, " _
& "items4, branch4 " _
& "FROM products1 " _
& "WHERE items4 > 0"
 
P

peljo via AccessMonster.com

Marshall said:
I have a perfectly normal query giving the right results. but when i copy it
and try to use it as sql i get red letters.May be i will have to change the
[quoted text clipped - 3 lines]
= " & [productid]) AS Expr1, products1.items4, products1.branch4 FROM
products1 WHERE (((products1.items4)>0))"

The interior quotes are wrong and I can't tell if it was all
on one line or you did not use proper line continuations.

I would write it more like:

trsql = "SELECT Productid, " _
& "DLookUp(""grade"",""products"", " _
& """productid = " & productid & """") AS Expr1, " _
& "items4, branch4 " _
& "FROM products1 " _
& "WHERE items4 > 0"


Thank you so much !
 

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

addition with 0 1
Update query 2
Quantity on hand calculation 1
commas 2
Multiple paramerter values in one text box 4
Code help 3
*Scratching My Head* - I need help 4
Code wont work 2

Top