Answered by:
Conditional background image

Question
-
Hi all,
I would like to set up a watermark on the report using the background image on the body. The watermark visibility is controlled by the status of the record and each record starts with a new page. Is there any way to refer to the status of the record in the body section? ReportItems does not work.
Thx.
Wednesday, August 18, 2010 1:51 AM
Answers
-
Hi,
You cannot refer the fields collection from the report's body. However to achive your requirement,
1. After adding the dataset, add a rectangle control to the report body area and expand the size of the rectangle to have as much as you need within the pagesize. (consider the report's pagesize and margins when sizing the rectangle)
2. Drag the fields to be displayed from dataset to the rectangle control
3. Add two images to the report as embedded. (for example name them as TestImage1 and TestImage2). Please refer http://msdn.microsoft.com/en-us/library/ms156482.aspx for more details adding images to the reprort.
4. Select rectangle, and click the + sign on the properties BackgroundImage
5. Select the source (external, embedded or database). (In this case select embedded).
6. Enter the below expression in the value. Below expression is to simply to apply a different image on alternate pages. You may use the expression referring the fields collection to suit your needs. In the below code, dataset name is assumed as "DataSet1"
=IIF(ROWNUMBER("DataSet1") mod 2=1,"TestImage1","TestImage2")
Now please run the report and observe the result. You would see the image TestImage1 and TestImage2 appearing on the page alternately.
Hope this helps. Regards
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH- Proposed as answer by Jinchun ChenMicrosoft employee Thursday, August 19, 2010 6:36 AM
- Marked as answer by Jinchun ChenMicrosoft employee Tuesday, September 7, 2010 3:10 AM
Wednesday, August 18, 2010 6:07 AM
All replies
-
Hi,
You cannot refer the fields collection from the report's body. However to achive your requirement,
1. After adding the dataset, add a rectangle control to the report body area and expand the size of the rectangle to have as much as you need within the pagesize. (consider the report's pagesize and margins when sizing the rectangle)
2. Drag the fields to be displayed from dataset to the rectangle control
3. Add two images to the report as embedded. (for example name them as TestImage1 and TestImage2). Please refer http://msdn.microsoft.com/en-us/library/ms156482.aspx for more details adding images to the reprort.
4. Select rectangle, and click the + sign on the properties BackgroundImage
5. Select the source (external, embedded or database). (In this case select embedded).
6. Enter the below expression in the value. Below expression is to simply to apply a different image on alternate pages. You may use the expression referring the fields collection to suit your needs. In the below code, dataset name is assumed as "DataSet1"
=IIF(ROWNUMBER("DataSet1") mod 2=1,"TestImage1","TestImage2")
Now please run the report and observe the result. You would see the image TestImage1 and TestImage2 appearing on the page alternately.
Hope this helps. Regards
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH- Proposed as answer by Jinchun ChenMicrosoft employee Thursday, August 19, 2010 6:36 AM
- Marked as answer by Jinchun ChenMicrosoft employee Tuesday, September 7, 2010 3:10 AM
Wednesday, August 18, 2010 6:07 AM -
Hi Mohamed
I'm struggling to implement the answer here - could I ask you to help?
If I want the background image on the body to change based on the current page's value of a field in a group on the page, how would I reference that value? If the image was in the rectangle/table, I could do:
=Iif(Fields!TestField.Value = 1, "Image1", "Image2")
But because the rectangle on the body is not part of the group, I don't understand how to reference values in the group as they are on that page? Using the ReportItems worked for my headers, but not in the body.
Any help appreciated,
James
Wednesday, October 12, 2016 2:54 PM