Reporting (Crystal)

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
Hi guys,

I'm doing a few crystal reports to add to my demo for my users to see current stage of development and I was wondering;

what is the best way of displaying reports?
a) Seperate form and report viewer for each report
b) One form and one report viewer, and bind viewer to report dependent on user selection?

point b) would be nice, but I'm using an MDI parent / child system, so would there be a way on the Report Form to code the following
IF mdiparent.mnuReport1.clicked THEN
cvReport.DataSource(Report1)
ELSEIF mdiparent.mnuReport2.clicked THEN
cvReport.DataSource(Report2)

...I know the above isn't real code, but trying to make the question easier to represent!

Cheers
Luke
 
Global Variables

A Global Variable used to hold the report number could be passed to the report viewer form and used to determine which report to display.

IF ReportNumber = 1 THEN
Dim Test1 As New Report1
cvReport1.DataSource(Report1) 'Set datasource and parameters
End If

IF ReportNumber = 2 THEN
Dim Test1 As New Report2
cvReport2.DataSource(Report2) 'Set datasource and parameters
End If

CrystalReportViewer1.ReportSource = Test1
CrystalReportViewer1.Refresh()

On your menu click set the report number and call the viewer form.
 
Thanks for that David. You've been a big help recently.

Another question (for everyone),

I don't like the Crystal Report Parameter box it brings up and asks for the value. No matter what I've tried I can not get the drop down box to list all Customers in my Customer table.

Is there a way of passing the parameter at runtime, using a modal form? I.E. when the user clicks "Customer Report" from the MDI menu, a modal form pops up with a combo box populated by Customers. Then when the user selects a customer, and clicks OK, it passes this customer name on as the parameter to the report viewer form displaying the customer report?

I'm still a little edgy with global variables etc as I haven't had to use any really yet, so if someone could explain a little more easily...

Ta,
L
 
sounds stupid, but how do I set ParamValue as a global variable?? I can quite easily talk and draw what I want to do, but can't yet get it into programming!!!

On my modal form I have the combobox populated with customername, so I'm assuming I now need to set the value selected from the combobox as a global variable called ParamValue??
Then on my form with the report viewer, add
report.SetParameterValue ("CustomerName", ParamValue)

?

Cheers!!!!
L
 
Global Variables in a moldue

Add a Module to your project called 'PublicVariables'. Add statements like these to the module.

Public iCurrentPartid As Integer
Public tCurrentPartName As String

the module makes the variables 'iCurrentPartId' & 'tCurrentPartName' available to all forms in the project.

On FORM1 set the variables to something:
iCurrentPartid = Grid.Columns("part id").Value
or
tCurrentPartName = TextBox2.text

call FORM2


then on form2 you can set anything to the public variable, such as an SQL Parameter.

SqlSelectCommand1.Parameters("@partid").Value = iCurrentPartid
or
textbox1.text = tCurrentPartName

hope this helps
 
Back
Top