Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Dynamic report header based on condition Expand / Collapse
Author
Message
Posted Monday, March 30, 2009 4:41 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 9, 2012 10:59 PM
Points: 229, Visits: 870
I have a requirement to show the company name in the report header based on the login user id. User id and his corresponding comapny name is stored in a database(Table). How to achieve this?. Any help is greatly appreciated.



-----------------------------------------------------------------------------------------------------------------------------------------------------------
Please feel free to let me know if you are not clear or I’ve misunderstood anything.

Thanks,
Arunkumar S P

Post #685955
Posted Monday, March 30, 2009 6:57 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:07 AM
Points: 11,157, Visits: 12,899
Sounds like you need a dataset that returns the company name with a parameter for user id.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #686046
Posted Monday, March 30, 2009 7:16 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 9, 2012 10:59 PM
Points: 229, Visits: 870
I placed the text box in the page header and added the following expression

=First(Fields!companyname.Value, "DataSet_ServiceCenterComapnyName")

But I'm getting the following error

An error occured during local report processing
The expression for the textbox 'companyname' refers to a field.Fields cannot be used in page header or footer


-----------------------------------------------------------------------------------------------------------------------------------------------------------
Please feel free to let me know if you are not clear or I’ve misunderstood anything.

Thanks,
Arunkumar S P

Post #686067
Posted Monday, March 30, 2009 11:09 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, June 5, 2013 1:53 PM
Points: 16, Visits: 282
Hi,

It is not possible to access Fields values in Report Header and Footer,follow this approach:

1.Fetch company Name by user id from Database.
2.Put a Text Box in the Body area of report (TextBox Name: CompayName)
3.Put your expression in the Text Box
i.e (Fields!companyname.Value, "DataSet_ServiceCenterComapnyName")
4.Set the TextBox as hidden.
5.In header put ReportItems!CompanyName.Value

After the 5th step you will get the company name in the Header.

Do let me know if any thing is unclear.

Thanks,
Richa
Post #686732
Posted Tuesday, March 31, 2009 1:00 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 9, 2012 10:59 PM
Points: 229, Visits: 870
Thanks for your response Richa

But i'm getting the CompanyName in page header only in the first page not in all the page of the header.
Please help me to solve this issue. I need report header(CompanyName) in all the page of the report.



-----------------------------------------------------------------------------------------------------------------------------------------------------------
Please feel free to let me know if you are not clear or I’ve misunderstood anything.

Thanks,
Arunkumar S P

Post #686759
Posted Tuesday, March 31, 2009 4:03 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 9, 2012 10:59 PM
Points: 229, Visits: 870
Ya.. i solved this in the below manner

I created a parameter(Report_Parameter_1) and get the default value as CompanyName from dataset

I kept a text box in the page header and added the following code

=Parameters!Report_Parameter_1.Value

Now it is dispalying the CompanyName in report header for all the pages.


But good effort Richa.Thanks for your reply



-----------------------------------------------------------------------------------------------------------------------------------------------------------
Please feel free to let me know if you are not clear or I’ve misunderstood anything.

Thanks,
Arunkumar S P

Post #686825
Posted Wednesday, April 1, 2009 12:59 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 6:56 AM
Points: 497, Visits: 1,969
I get around this problem by putting a couple of rows at the top of my report table to hold my "header" variables or expressions. I put them above the column headers and the values print on each page. I put a first() around the data item so I only get one value.
Post #688292
Posted Monday, May 16, 2011 3:42 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 15, 2013 10:47 AM
Points: 2, Visits: 4
richa.gupta (3/30/2009)
Hi,

It is not possible to access Fields values in Report Header and Footer,follow this approach:

1.Fetch company Name by user id from Database.
2.Put a Text Box in the Body area of report (TextBox Name: CompayName)
3.Put your expression in the Text Box
i.e (Fields!companyname.Value, "DataSet_ServiceCenterComapnyName")
4.Set the TextBox as hidden.
5.In header put ReportItems!CompanyName.Value

After the 5th step you will get the company name in the Header.

Do let me know if any thing is unclear.

Thanks,
Richa


Hi Richa,

I can't get the report to run using ReportItems!COMMODITY.Value. It will work with Fields!COMMODITY.Value but won't change value on commodity breaks.

Is there a way to do this with dynamic header data? For example, I am processing 2 crop years (2009 and 2010) with 2 commodities (grapes, dried fruit). Each crop year has grapes and dried fruit. I want the header data to change when crop year and/or the commodity changes.
Thank you,
Jerri

Post #1109861
Posted Tuesday, May 17, 2011 10:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 15, 2013 10:47 AM
Points: 2, Visits: 4
I got it to work. I was trying to put the reportitems in the column headers and when I moved it to the header area it worked.
Post #1110376
Posted Friday, May 9, 2014 7:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 27, 2014 10:49 AM
Points: 4, Visits: 39
It is entirely possible to do this:

Create a hidden field in the details record to hold the value you want to see in the header
Name the textbox "header_field_1"
populate it with the database value you want to display on the header.
Next, within the header, reference the report textbox in an expression where you store the value: =ReportItems!header_field_1.value

note that this is different from referenceing the data value from your dataset.


HERE IS THE ISSUE THAT I CANNOT FIGURE OUT THOUGH.....

When the report renders it looks fine... but when you go to print it, the headers become static and only the data from the first row is printed.
If anyone figures this one out then you have my votes.
Post #1569249
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse