Filtering data in CR

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
In my windows form, I need the user to select a client name from a combo box
and click on a button that opens another form having CRViewer showing the
data for that client selected.
I connected to the SQL database where the cbo box gets the clients names
from and I can see the names in cbo box. I created my CR and put the CRViewer
on another windows form. What's next? I need help with the code.
Thanks in advance
 
Hi TS,

There are several ways to do this. Perhaps the most straightforward would
be to pass a parameter to the report and set the report's record selection
criteria to include only the client names who match the parameter.

HTH,

Bernie Yaeger
 
Thanks for your response. Can you tell me how the code for this looks like.
Or do you know of any white papers that can help with that.
 
Hi TS,

Here's an example of passing a global variable to the report in order to
filter that report. 'globals' is a module that has global scope and has a
string variable in it called 'gl_selectionstring:

Dim mglobals As New globals
mglobals.gl_selectionstring = "{bnlsum.invnum} >= '" & startnumbox.Text &
Chr(39) & " and {bnlsum.invnum} <= '" & endnumbox.Text & Chr(39)

gl_browseprintvar = "f:\imcapps\bnlinv.rpt"

Dim newmdichild As New reportprinter_viewerparam

newmdichild.Text = "BNL Summary Invoice"

newmdichild.Show()

reportprinter_viewerparam is a form that displays the report. In that form,
here's the code for that report:

CrystalReportViewer1.SelectionFormula = mglobals.gl_selectionstring

CrystalReportViewer1.ReportSource = "f:\imcapps\bnlinv.rpt

HTH,

Bernie Yaeger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top