SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dynamic report header based on condition


Dynamic report header based on condition

Author
Message
Arunkumar S P
Arunkumar S P
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2717 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


Jack Corbett
  Jack Corbett
SSC Guru
SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)

Group: General Forum Members
Points: 71016 Visits: 14949
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
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

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
Arunkumar S P
Arunkumar S P
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2717 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


richa.gupta
richa.gupta
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 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
Arunkumar S P
Arunkumar S P
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2717 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


Arunkumar S P
Arunkumar S P
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2717 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


sing4you
sing4you
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1030 Visits: 2093
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.
jfowler-1157930
jfowler-1157930
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 7
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
jfowler-1157930
jfowler-1157930
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 7
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.
dblowers
dblowers
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 45
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search