Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Constant in a query ? (Access 2000)

    Constant in a query


    Can i use a constant in a query ? I have a constant
    Public Const rate As Double = 10
    Can i use it in the query ? I want to multiply the field [liters] with the constant rate, but Access does not accept the rate as a constant, instead it always put it into brackets as it is a field. I tried to write rate in sql, but after that access shoewed
    "unknown parameter".

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Constant in a query ? (Access 2000)

    You cannot use constants or variables in queries because SQL doesn't know anything about constants and variables. You would have to create a public function that would return the constant value and use that in the query.

    Public Function cDOUBLE() As Integer
    cDOUBLE= 10
    End Function

    Then in the query, you would use the expression [liters] * cDOUBLE()

    BTW, I used cDOUBLE instead of Double as the constant/function name because "double" is a datatype.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Constant in a query ? (Access 2000)

    Thank you for the advice.I will apply it now

Posting Permissions

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