• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2616
  • Last Modified:

How to create a Constant in SSRS 2005

In SSRS 2005's Expression window there is a branch on the tree called Constants.  How do I create a string constant?
  • 3
  • 2
1 Solution
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.

BostonMAAuthor Commented:
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'
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.

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

BostonMAAuthor Commented:
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?
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.
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.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now