Sql Query Based on Cell Value

  • Hi,
    Small follow up question. How would i change this command if i wanted to add more criteria linked to a different cell? (and where...)

    Specifically I have some code that works that thanks to this forum I was able to create that looks like this




    ...but when i try to add another criteria linked to a cell such as

    Code
    .Open "SELECT * FROM organization where organization.organizationid = " & Sheets("SQL").Range("b" & counter).Value[B] and organization.docclauseid = " & Sheets("SQL").Range("c" & counter).Value

    [/B]

    i obviously can't get the right command figured out

    Thanks so much

  • Re: Sql Query Based On Spreadsheet Cell


    Try this:

    Code
    "SELECT * FROM organization where organization.organizationid = " & Sheets("SQL").Range("b" & counter).Value  & " and organization.docclauseid = " & Sheets("SQL").Range("c" & counter).Value



    I think you forgot & " and organization.docclauseid

  • Re: Sql Query Based on Cell Value


    Dennisdlin,

    Please read the rules which you agreed to when signing up.

    In future all code must be wraped in code tags.
    Do not post questions in other members threads - start your own question.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!