Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 fieldname

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-09 : 10:56:21
Hi,
How do I get the name of a field in the expression please?
is it something like:
=FieldName() ?
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-09 : 11:28:46
use fields collection
=Fields!yourfieldname.value
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-09 : 11:56:27
Basically I am trying to jump from one report to another which is fine.
One of the parameters to pass from report1 to report2 is the name of the field which populates the textbox in report1. This is the name I would like to pass and at present I just hard code that.
So I believe !yourfieldname willnot work in this case.
Let's say the name of the field is field2 so I can not use =Fields!Field2.value because when I click on fields in the expression, then it is just empty
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-09 : 12:05:25
quote:
Originally posted by arkiboys

Basically I am trying to jump from one report to another which is fine.
One of the parameters to pass from report1 to report2 is the name of the field which populates the textbox in report1. This is the name I would like to pass and at present I just hard code that.
So I believe !yourfieldname willnot work in this case.
Let's say the name of the field is field2 so I can not use =Fields!Field2.value because when I click on fields in the expression, then it is just empty


before coming into any kind of belief can you first try to see if it works. I didnt understand what you meant by
when I click on fields in the expression, then it is just empty

provided your container is correctly linked to dataset, you can use fields!field2.value in jump to expression as long as field2 is available inside selected dataset
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-09 : 12:18:05
Sorry, Yes I did try it first.
The dataset is built using a stored procedure (sp)
The sp returns several fields i.e. field1, field2, etc...
I have placed these fields onto the appropriate textboxes.
So forexample, field2 is placed into a textbox on the report.
The value returned is correct. Then I go to the properties of the textbox.
In there I would like to get the name of the field from an expression.
When I click on fields, it just shows <ALL> only.
When I click on the datasetname then it shows only the fields as sum(field1), sum(field2) because that is what i am doing in the sp.
So still not sure how to get the NAME.
May be I should have said that I would like to get the NAME of the textbox which I see now it is different to the fieldname.
So to confirm, how do I get the name of the textbox in an expression. This textbox is holding the field I dragged from the dataset.
Thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-09 : 12:27:07
quote:
Originally posted by arkiboys

Sorry, Yes I did try it first.
The dataset is built using a stored procedure (sp)
The sp returns several fields i.e. field1, field2, etc...
I have placed these fields onto the appropriate textboxes.
So forexample, field2 is placed into a textbox on the report.
The value returned is correct. Then I go to the properties of the textbox.
In there I would like to get the name of the field from an expression.
When I click on fields, it just shows <ALL> only.
When I click on the datasetname then it shows only the fields as sum(field1), sum(field2) because that is what i am doing in the sp.
So still not sure how to get the NAME.
May be I should have said that I would like to get the NAME of the textbox which I see now it is different to the fieldname.
So to confirm, how do I get the name of the textbox in an expression. This textbox is holding the field I dragged from the dataset.
Thank you


i didnt understand why you need to pass the name of textbox in jump to report. you should be only passing the actual value that it holds or displays which you can get from fields! collection. name will just be a text so not sure why you're interested in that.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 02:11:55
quote:
Originally posted by visakh16

quote:
Originally posted by arkiboys

Sorry, Yes I did try it first.
The dataset is built using a stored procedure (sp)
The sp returns several fields i.e. field1, field2, etc...
I have placed these fields onto the appropriate textboxes.
So forexample, field2 is placed into a textbox on the report.
The value returned is correct. Then I go to the properties of the textbox.
In there I would like to get the name of the field from an expression.
When I click on fields, it just shows <ALL> only.
When I click on the datasetname then it shows only the fields as sum(field1), sum(field2) because that is what i am doing in the sp.
So still not sure how to get the NAME.
May be I should have said that I would like to get the NAME of the textbox which I see now it is different to the fieldname.
So to confirm, how do I get the name of the textbox in an expression. This textbox is holding the field I dragged from the dataset.
Thank you


i didnt understand why you need to pass the name of textbox in jump to report. you should be only passing the actual value that it holds or displays which you can get from fields! collection. name will just be a text so not sure why you're interested in that.


Hello again,
I have to pass the name so that based on that name the relevant calculations are carried out. This is a business requirement...
So still not sure how to pass the name of the textbox control. Note that this is the name which shows up when I hover over the textbox i.e. securities shows as the name, type is shows as textbox, vlaue is shows as =(sum(Amount.value), datasetname)
Please note that I am interested to get the Name section.
Any thoughts please?
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 02:30:25
what calculations you're trying to perform based on container textbox name? I cant really understand why your container name is a determining factor in your calculations at all.perhaps you could give some background on your calculations

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 02:40:31
The summary report is being populated with the different sum(Amount) into the textboxes...
The stored procedure in the detailed report is run based on the parameter being passed by clicking the textbox in the summary report... The parameter in the detailed report stored procedure takes a string to decide on the where clause of a table in the SP. This where clause is to do with a varchar field in one of the tables being joined.
So, the parameter i.e. the name of the textbox decides on the correct where clause...
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 02:51:00
quote:
Originally posted by arkiboys

The summary report is being populated with the different sum(Amount) into the textboxes...
The stored procedure in the detailed report is run based on the parameter being passed by clicking the textbox in the summary report... The parameter in the detailed report stored procedure takes a string to decide on the where clause of a table in the SP. This where clause is to do with a varchar field in one of the tables being joined.
So, the parameter i.e. the name of the textbox decides on the correct where clause...
Thanks


So it all has boiled down to single point - poor design
Its not a good method to pass string containing textbox name to decide on the where clause of a table in the SP.
In your summary report, what you need to do is to pass the value (not name) of category under which the summary is shown and this is to be used as a parameter in your detailed report and do the filtering based on it.

suppose if its like monthly sales report for 2009 like

Product Jan Feb Mar...
XCXV 125 200 100
JHG 39 75 112
..


then from each of total you pass the year, month name & product

then in your detail report you have params year,month name & product and you use them in query like

.....
WHERE YEAR(date) = @year
AND MONTH(date)=@monthnname
AND Product=@Product




------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 03:01:11
Yes, I understand.
But, what if it has to be the way I explained due to the fact that the sp was written based on business rules...
Without changing what you said, is there a way to get the name of the textbox in the expression?
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 03:05:46
quote:
Originally posted by arkiboys

Yes, I understand.
But, what if it has to be the way I explained due to the fact that the sp was written based on business rules...
Without changing what you said, is there a way to get the name of the textbox in the expression?
Thanks


if at all there's a way, i would suggest to change the sp to take values rather than string from report and do all the calculations

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 03:22:32
Ok, many thanks
Go to Top of Page
   

- Advertisement -