How to select fields to display in a report

Hello

I have a report with 10 data fields, I would like users to run a report and give them the option to include the data fileds they desire by checking their title on a check box. How do I include the fields on a report based on which checkbox is checked?

Thanks,

Victor
vcharlesAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
Try this idea

In the report create 10 formulas
They can simply be an empty string " "
Name the checkboxes as an array of checkboxes
Declare 2 integer variables
Index
FormulaIndex
Syntax for the application is approximate since I don't know .Net

In the application
DonorXML1.RecordSelectionFormula = "{Donor.DonorName} like " & "'*" & TextBox1.Text & "*'" & ""
FormulaIndex = 0
For Index = 0 to 9
    If CheckBox(Index) = CHCECKED then
          FormulaIndex  = FormulaIndex  + 1
          DonorXML1.Formulas(FormulaIndex 0.Text = CheckBox(Index).FieldName - Not Sure how you do this
    End if
With DonorXML1
CrystalReportViewer1.ReportSource = DonorXML1
End With

mlmcc
0
 
mlmccCommented:
There is no easy way to do that.

One way which leaves much whote space is to put all the fields on the report then using parameters suppress the ones not chosen.

Are all fields the same data type? For example all text ot numeric?

mlmcc
0
 
vcharlesAuthor Commented:
Yes the are all text, datasource is an XML file. How would you suppress the fields and how would it impact the spacing between the fields? Would they automatically rearrange?

Thanks,

Victor
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
mlmccCommented:
No they would not rearrange.

If they are all text fields then you could use formulas for the report

How will you call the report?
Formulas can be changed from the application.

mlmcc
0
 
vcharlesAuthor Commented:
I'm using the following approach with VB.NET:

DonorXML1.RecordSelectionFormula = "{Donor.DonorName} like " & "'*" & TextBox1.Text & "*'" & ""
With DonorXML1
CrystalReportViewer1.ReportSource = DonorXML1
End With

Thanks,

V.
0
 
mlmccCommented:
What version of Crystal?

mlmcc
0
 
vcharlesAuthor Commented:
version 2008
0
 
mlmccCommented:
Is that the standalone or the version that comes with VS2008?

mlmcc
0
 
vcharlesAuthor Commented:
It is the standalone version.
0
 
vcharlesAuthor Commented:
Hi,

Main problem is I need to rearrage the columns when I remove certain columns, is that at all possible in Crystal Reports?

Thanks for the code.

Victor
0
 
mlmccCommented:
No.

However the code I provided uses the formulas from left to right assuming they are put on the report in that order.

mlmcc
0
 
vcharlesAuthor Commented:
I will check to see if I can use this feature.

Thank you for the solution.

Victor
0
 
vcharlesAuthor Commented:
Thank You!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.