如何设置VS2010 Crystal Reports多重值以编程方式显示所有值 [英] How to set a VS2010 Crystal Reports multi value to show all programmatically
问题描述
我正在尝试学习如何使用Crystal Reports,并且已经在报表中设置了一个参数以允许多个值.效果很好,除了它在我运行报表时提示用户输入一个或多个值.我真正想要的是默认操作是所有值都在没有用户提示的情况下显示.如果他想过滤到一个子集,那么他可以.我进行了搜索,但似乎找不到任何地方的方法.
预先感谢您的任何建议,
普雷斯顿
Hi,
I am trying to learn how to use Crystal Reports and I have set up a parameter in my report to allow multiple values. This works well except that it prompts the user to enter a value or values when I run the report. What I would really like is for the default action to be all values are displayed with no user prompt. If he wants to filter to a subset then he can. I have searched but can not seem to find how to do this anywhere.
Thanks in advance for any advice,
Preston
Surely there is a way to programatically set the value of the multi-parameter to all?
推荐答案
使用Crystal Report,可以通过代码传递参数(绕过Crystal.报告用户界面以输入参数).这似乎是您要实现的目标:
VS 2010-以编程方式将参数传递给Crystal报表 [
With Crystal Report, you can pass the parameter via code (bypassing the Crystal Report UI to input parameters). This looks to be what you are trying to accomplish:
VS 2010 - Passing Parameter Programatically to Crystal reports[^]
The other option would be to create your own UI and then pass the selected values to the report using either a selection formula or parameters.
经过更多的挖掘和实验,我发现了我需要使报告表现出我想要的困惑.这是关键部分.要以编程方式设置参数值,请执行以下操作.
rpt.SetParameterValue("parm", "*");
然后在Crystal Reports菜单中,选择Report-> Selection Formula-> Saved Data ...
添加以下公式
After a lot more digging and experimentation I found the pieces of the puzzle I needed to make the report behave like I wanted. Here are the key pieces. To set the parameter value programatically you do the following.
rpt.SetParameterValue("parm", "*");
Then in the Crystal Reports menu select Report->Selection Formula->Saved Data...
add the following formula
if HasValue({?parm}) Then
if {?parm} = "*" Then
True
else
{?parm} = {Table.FieldEquatedToParm}
else
True
这将允许报表出现并显示所有值,而不会提示用户输入值.然后,如果用户决定要过滤报告,则可以使用参数面板选择过滤值.如果增加可过滤列的数量,该公式就会令人讨厌.
This will allow the report to come and display all the values without prompting the user to enter a value. Then if the user decides they want to filter the report they can use the parameter panel to choose a filter value. The formula get kind of nasty if increase the number of filterable columns though.
这篇关于如何设置VS2010 Crystal Reports多重值以编程方式显示所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!