Friday, February 24, 2012

custom code to populate parm default

I am using custom code to retrieve the current year to populate the default
year parameter for a report. The custom code correctly retrieves the year
when tested within the body of the report. However, when referenced as an
expression code.CurYr in the "default" seection of the report parameters, it
causes the preview pane to grey-out the prompt. I can not enter anything in
the prompt and it does not contain a value. When I remove the custom code
from the expression for the "default", the prompt is white and available to
me for entry. Does anyone have any idea why this is happening, or how I can
default the current year into my prompt parameter?
Thank you...On May 1, 8:24 am, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> I am using custom code to retrieve the current year to populate the default
> year parameter for a report. The custom code correctly retrieves the year
> when tested within the body of the report. However, when referenced as an
> expression code.CurYr in the "default" seection of the report parameters, it
> causes the preview pane to grey-out the prompt. I can not enter anything in
> the prompt and it does not contain a value. When I remove the custom code
> from the expression for the "default", the prompt is white and available to
> me for entry. Does anyone have any idea why this is happening, or how I can
> default the current year into my prompt parameter?
> Thank you...
I don't think you need to use custom code. Using a date part function
that SSRS will accept should do the trick. Try =YEAR(getdate()) or
=YEAR(now())|||=year(now is acceptable , HOWEVER, the preview pane still greys-out the year
prompt and does Not let me enter anything. It also does Not display the
results for the =year(now expression
For some reason, the preview pane doesn't work properly when an expression
provides the default value. In the past, I have specified a specific default
value, or used a query to load and had no difficulty.
Thoughts?
"toolman" wrote:
> On May 1, 8:24 am, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> > I am using custom code to retrieve the current year to populate the default
> > year parameter for a report. The custom code correctly retrieves the year
> > when tested within the body of the report. However, when referenced as an
> > expression code.CurYr in the "default" seection of the report parameters, it
> > causes the preview pane to grey-out the prompt. I can not enter anything in
> > the prompt and it does not contain a value. When I remove the custom code
> > from the expression for the "default", the prompt is white and available to
> > me for entry. Does anyone have any idea why this is happening, or how I can
> > default the current year into my prompt parameter?
> >
> > Thank you...
> I don't think you need to use custom code. Using a date part function
> that SSRS will accept should do the trick. Try =YEAR(getdate()) or
> =YEAR(now())
>|||On May 2, 3:24 pm, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> =year(now is acceptable , HOWEVER, the preview pane still greys-out the year
> prompt and does Not let me enter anything. It also does Not display the
> results for the =year(now expression
> For some reason, the preview pane doesn't work properly when an expression
> provides the default value. In the past, I have specified a specific default
> value, or used a query to load and had no difficulty.
> Thoughts?
>
> "toolman" wrote:
> > On May 1, 8:24 am, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> > > I am using custom code to retrieve the current year to populate the default
> > > year parameter for a report. The custom code correctly retrieves the year
> > > when tested within the body of the report. However, when referenced as an
> > > expression code.CurYr in the "default" seection of the report parameters, it
> > > causes the preview pane to grey-out the prompt. I can not enter anything in
> > > the prompt and it does not contain a value. When I remove the custom code
> > > from the expression for the "default", the prompt is white and available to
> > > me for entry. Does anyone have any idea why this is happening, or how I can
> > > default the current year into my prompt parameter?
> > > Thank you...
> > I don't think you need to use custom code. Using a date part function
> > that SSRS will accept should do the trick. Try =YEAR(getdate()) or
> > =YEAR(now())- Hide quoted text -
> - Show quoted text -
Apparently once you establish an expression as your default that's
what you get without options for editing.
The way around it (although it bugs me to have to jump the extra
hoops) is as follows.
Create a new Text type dataset and enter this query SELECT
year(getdate()) AS 'Year'
In the Parameters dialog, set the default to From query and use the
new dataset. This plugs in the year but allows it to be edited.|||Got it... Thanks! :)
"toolman" wrote:
> On May 2, 3:24 pm, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> > =year(now is acceptable , HOWEVER, the preview pane still greys-out the year
> > prompt and does Not let me enter anything. It also does Not display the
> > results for the =year(now expression
> >
> > For some reason, the preview pane doesn't work properly when an expression
> > provides the default value. In the past, I have specified a specific default
> > value, or used a query to load and had no difficulty.
> >
> > Thoughts?
> >
> >
> >
> > "toolman" wrote:
> > > On May 1, 8:24 am, ppbedz <ppb...@.discussions.microsoft.com> wrote:
> > > > I am using custom code to retrieve the current year to populate the default
> > > > year parameter for a report. The custom code correctly retrieves the year
> > > > when tested within the body of the report. However, when referenced as an
> > > > expression code.CurYr in the "default" seection of the report parameters, it
> > > > causes the preview pane to grey-out the prompt. I can not enter anything in
> > > > the prompt and it does not contain a value. When I remove the custom code
> > > > from the expression for the "default", the prompt is white and available to
> > > > me for entry. Does anyone have any idea why this is happening, or how I can
> > > > default the current year into my prompt parameter?
> >
> > > > Thank you...
> >
> > > I don't think you need to use custom code. Using a date part function
> > > that SSRS will accept should do the trick. Try =YEAR(getdate()) or
> > > =YEAR(now())- Hide quoted text -
> >
> > - Show quoted text -
> Apparently once you establish an expression as your default that's
> what you get without options for editing.
> The way around it (although it bugs me to have to jump the extra
> hoops) is as follows.
> Create a new Text type dataset and enter this query SELECT
> year(getdate()) AS 'Year'
> In the Parameters dialog, set the default to From query and use the
> new dataset. This plugs in the year but allows it to be edited.
>

No comments:

Post a Comment