Thursday, October 18, 2007

Database fields in Report header / footer

A database field can neither be placed in a report header nor in the footer. This will throw an error "The Value expression for the textbox <fieldname> refers to a field. Fields cannot be used in page headers or footers".

There is however a workaround. Place a hidden textbox in the report body call it tb_hidden and assign to this the database field that you need in the header. Place a textbox in the report header and assign the hidden textbox's value to it
ex: =reportitems!tb_hidden.Value

This however as a drawback, the value will appear only in the first page. If your report runs into many pages then you need to take a different approach.

Pass the value to appear in the header as a parameter from your .aspx page call it database_field. Assign this to the textbox in the header.
ex: =Parameters!database_field.Value

1 comment:

Anonymous said...

You can also use an internal report parameter which gets its value from a dataset. The dataset can utilize other parameters passed to the report (e.g. from a web page) to lookup the value for the parameter that will be used for displaying in the report header.

------------
Ruslan Urban