Error with constant


Error with Constant


I have a RowSource that functions very good without the constant StrIn like that :

strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
" FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
" WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) In (118,119,120,121,124,950,992,1008)))"


I want however to introduce a constant like that:

Public Const strIn = " In (118,119,120,121,122,123,124,960))"

In substituting the constant in my RowSource i obtain blank fields and my list box remains blank.It seems that I have an error
either in the constant or in the code itself,may be some brackets more or less,i cannot find out the reason.
Can somebody help me? The code under question that i want make working is the following

strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
" FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
" WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn & " )))"






Comments

  • It seems to be a bracket problem. you write 3 at the end and must be only 1.

    I think problem is:
    Public Const strIn = " In (118,119,120,121,122,123,124,960))"
    HERE YOU ARE PUTTING ONE MORE ----^
    ...
    strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn & " )))"
    SO HERE ----^ THERE MUST BE ONE LESS (PUT ON CONSTANT LINE)

    The correct solution is the next:
    Public Const strIn = " In (118,119,120,121,122,123,124,960)" 'ONLY OWN BRACKETS
    ...
    strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn & " ))"

    I hope could help you.

    :
    : Error with Constant
    :
    :
    : I have a RowSource that functions very good without the constant StrIn like that :
    :
    : strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    : " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    : " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) In (118,119,120,121,124,950,992,1008)))"
    :
    :
    : I want however to introduce a constant like that:
    :
    : Public Const strIn = " In (118,119,120,121,122,123,124,960))"
    :
    : In substituting the constant in my RowSource i obtain blank fields and my list box remains blank.It seems that I have an error
    : either in the constant or in the code itself,may be some brackets more or less,i cannot find out the reason.
    : Can somebody help me? The code under question that i want make working is the following
    :
    : strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    : " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    : " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn & " )))"
    :
    :
    :
    :
    :
    :
    :

  • :
    : Error with Constant
    :
    :
    : I have a RowSource that functions very good without the constant StrIn like that :
    :
    : strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    : " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    : " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) In (118,119,120,121,124,950,992,1008)))"
    :
    :
    : I want however to introduce a constant like that:
    :
    : Public Const strIn = " In (118,119,120,121,122,123,124,960))"
    :
    : In substituting the constant in my RowSource i obtain blank fields and my list box remains blank.It seems that I have an error
    : either in the constant or in the code itself,may be some brackets more or less,i cannot find out the reason.
    : Can somebody help me? The code under question that i want make working is the following
    :
    : strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    : " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    : " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn & " )))"
    :
    :
    :
    :
    :
    :
    :
    This is the end of your SQL statement that works:
    ((orders.customerid) In (118,119,120,121,124,950,992,1008)))"

    Make your constant:
    Constant = "In (118,119,120,121,124,950,992,1008)))"

    And make your statement:
    strBas = " SELECT orders.orderid, orders.orderdate, customers.CompanyName, orders.customerid " & _
    " FROM orders INNER JOIN customers ON orders.customerid = customers.Customerid " & _
    " WHERE (((orders.orderdate)>" & CnstYear & ") AND ((orders.customerid) " & strIn

    It looks like you're adding a lot of extra closing parentheses.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories