How to create a Constant in SSRS 2005

Posted on 2009-04-20
Last Modified: 2012-05-06
In SSRS 2005's Expression window there is a branch on the tree called Constants.  How do I create a string constant?
Question by:BostonMA
    LVL 8

    Expert Comment

    From MSDN:
    Select the Constants node to define expressions that include a constant value. Constants are used to specify color, font, and enumerations.

    Not all items will support expressions that can be set to a constant. If a property cannot be set to constant value, the description provides this information.

    So depending on what item you want to use an expression on it may or may not be available and you cannot create the yourself.

    LVL 4

    Author Comment

    My question still is, how do I actually define the constant?  There doesnt seem to be a place to do it, ie in my screen shot, where do i click to make a constant? Everytime I make a text box it just says 'No constants are availible for this propoperty'
    LVL 8

    Expert Comment

    Yes thats what It stated in my previous post "Not all items will support expressions that can be set to a constant", so you cant make a constant only use those that are available.

    Like in the screen clip below using it on a property where its allowed.

    LVL 4

    Author Comment

    Everytime I look at an expression window in our reports, I never see the color options that you have.  Can you give me an example of what object your looking at and what 'Custom' and 'Web' are?
    LVL 8

    Expert Comment

    The property I took a screenshot from was the background color of a cell in the report.
    The Custom can be any color, the web are 'aproved' save colors to use for the web.

    Try it on a font property and you will see a different set of constants.
    LVL 11

    Accepted Solution

    Hi.. you might  able to create your own constant using custom code but it wont appear in the constant list in the expressions dialogbox.

    If you go to your report properties then select the code tab.. in there you type your custom vb code and declare a globle variable. eg:

    Public Myconst AS StringPublic Function myFunct() AS String           Myconst="Hello!"           return MyconstEnd Function

    and in the textbox or field where your using the constant, you refer to your constant using the notation in any part of your expression:


    I'm not too sure if this example will work as I dont know much vb but this should help you get started.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
    It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now