Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error in code (Access 2000)

    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))"

  2. #2
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: error in code (Access 2000)

    I'm a bit rusty in the Access dept., but since the experts may be snoozing at the moment...

    I suspect what you need to do is double the quotation marks within the string, like this:

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

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: error in code (Access 2000)

    Thank you for your reply.This time i got no error with red letter, but on opening the form the looked up name did not appear.What may be he reason?
    I also tried other ways,again no error, but again the looked up name was not displayed
    strsql = "SELECT Productid, " _
    & "DLookUp(""grade"",""products"", " _
    & """productid = " & productid & """") AS Expr1, " _
    & "items4, branch4 " _
    & "FROM products1 " _
    & "WHERE items4 > 0"
    ============================
    strsql = "SELECT Productid, DLookUp('grade','products','productid=' & [productid]) AS Expr1, items4, branch4 FROM products1 WHERE items4>0"
    =================
    strsql = "SELECT A.Productid, B.grade, A.items4, A.branch4 FROM products1 A INNER JOIN products B ON A.productid=B.productid WHERE A.items4>0"
    =================================================

  4. #4
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: error in code (Access 2000)

    Just to let you know that i i found out the error and succeeded.You suggestion was ok and now it works excellent.Thank you very much !!

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: error in code (Access 2000)

    You already have the solution, but see <!post=Chr() function and quotes within strings (all),230516>Chr() function and quotes within strings (all)<!/post> for more info.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •