Crystal Report TextBox - crystal-reports

I am working on crystal report, i need to pass value(from Winforms) to crystal report
Textbox control's like Period:10-11-2009 To 13-11-20009 this value I want pass for crystal report textbox control
advance wishes...

see this link it shows how to pass parametar to crystal report.There are many more examples for this just ask google
link to an example

You can pass values to crystal using parameters. Then you can display these in the reports.

See the code below
//Initialize your report
sample_report yourReport = new sample_report();
CrystalDecisions.CrystalReports.Engine.TextObject variableName=
(CrystalDecisions.CrystalReports.Engine.TextObject)
yourReport.Section2.ReportObjects["nameoftheTextboxInyourReport"];
variableName.Text = "Period:10-11-2009 To 13-11-20009";

You can add the from date and to date in the details or header column that you are passing through the data source to the crystal report .. drag those fields from the field explorer and put them into the text field

Just use parameters and pass the Textbox value :
Example in VB.NET :
Dim rptList As ReportDocument = New ReportDocument()
With rptList
.Load(strPath)
.SetDataSource(dtsData)
rptList.SetParameterValue("SomeName", yourTextBox.Text.trim)
End With
strPath is the path to your .rpt file and dtsData is the dataset.
in SetParameterValue define a name and value, just notice that you should create a parameter with the same name in your crystal report.

' txtName = textbox name in crystal report
' txtValue = text value to be passed to report
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject =RtpDocument.ReportDefinition.Sections(1).ReportObjects(txtName)
objText.Text = txtValue
CrystalReportViewer1.ReportSource = RtpDocument

Related

Crystal Report Export to excel using suppress

I have a problem with exporting rpt file to excel,
My requirement is to:
Display page numbers when printing from a Crystal Report (rpt) file and
Suppress the page number when exporting this to excel,
I am having trouble with the suppression and need help.
One way you can achieved by creating a static parameter as ExportFormat and put two value as 'default' and another one 'excel'..
Then add this parameter to your report with any string field notequalto the parameter..
finally in the PageNumber field in the suppress put this formula
if {?ExportFormat} = 'excel' then true else false
When ever user want to export to excel select "excel" if user want to view in crystal or any other export format select default..So that page number will suppress only when user select export format as 'excel'...

Display Jasper report file name

I'm creating a jasper report using iReports 5.2.0 and I want to display the report file name in it.
Can't find any variable that has that information and I would like to get an alternative to pass it in the parameters.
How can I do it?
When you design your report, make a new PARAMETER named, for instance: NAME_REPORT.
After that, put a TextField in your report, for example, in your Title section, and
put as value of your TextField the parameter like a expression: $P{NAME_REPORT}
When you preview your report, ask you to give a value to this parameter and then, you see the title with the name
of your report file.
In your java code you will do somethink like that:
parameters.put("NAME_REPORT", "myreport.jrxml");
.....
JasperFillManager.fillReport(report, parameters, connection)
.....

Crystal reports no data lable

I have a report containing some sub reports and in my main report i am showing the sub reports based on scan mode and status coming from query.
Now i need to show a message whenever sub reports don't have data.
I tried like this.
checked supress blank sub report and supress blank section for all reports.
1.Kept a text box in report footer of main report.
2.Took a field (Say Barcode) from sub report and passed to main report using shared variable.
3.In section expert of text box wrote like this.
not isnull(Barcode)
But it is not working.
Please suggest.
If I have understood this correctly the code below should work. Tip, avoid using NOT ISNULL. If possible just change the outcome order of your IF statement as below.
To make your formula more robust also, it's a great idea to add in the:
OR = ""
To account for any blank entries.
Final code:
IF Isnull({Barcode}) OR {Barcode} = "" THEN FALSE ELSE TRUE

'This field name is not known' error (Crystal Reports)

Here is a strange problem I have run into.
My record select formula is as follows, I have dumbed it down for purposes of this error:
reportDocument.RecordSelectionFormula = " {#ClientName} = 'Smith' "
If I copy this exact selection statement into Crystal it previews fine, but when run from .NET I get
'This field name is not known'.
The problem is occurring at the #ClientName formula field.
#ClientName simply contains:
formula = {aw_illust.CL1LNAM}
I can also set it to just a blank string (formula = "") and it still gives
'This field name is not known.'
Here is the strange part, if I bypass the formula and put the formula text straight into .NET everything works fine.
reportDocument.RecordSelectionFormula = " {aw_illust.CL1LNAM} = 'Smith' "
That is the same record selection, except with the '#ClientName' formula replaced with '{aw_illust.CL1LNAM}'. It just happens on this one report, I have many other Crystal Reports working with formulas referenced in .NET just fine. Any ideas?
Most likely you are not using your {#ClientName} formula anywhere on report; Crystal Reports tends to ignore unused fields, formulas etc. Place {#ClientName} field somewhere in report (header or some similar section) and suppress it - this way you don't mess up report design, but CR should know about that formula afterwards.
Which syntax has the formula? If it is crystal syntax then change it to basic syntax. Or change the content of the formula to crystal syntax (without "formula =")
You could create a parameter like {?ClientName} and set that from .NET, and then put a select formula in Crystal like {#ClientName} = {?ClientName}.
Can you save the report with the selection criteria you'd like then display what the reportDocument class sees using something like:
TextBox1.text = reportDocument.RecordSelectionFormula
This would confirm that your syntax is correct.
Same happened with me when I copied existing report to be used as the new one, You can first open report in report viewer ,In my case
but the query that loading report has no selection with name DateLocal Transaction so I got this error, the resolve is to either use only those that are require (Extras has nothing to do with the error) or rename selection value in query.

How can I disable Parameter Prompt at run time in Crystal Report XI?

How can I disable Parameter Prompt in sub report at run time in Crystal Report XI? I used Ms VS 2005 and report also included. Other report features is the same Crystal Report features. Other report not show prompt at run time which are not included Sub report. Prompt appeared one is included sub report. so you may hv any suggestion. let me know pls. thanks.
I solved it from this web site: http://www.it-sideways.com/2011/10/how-to-disable-parameter-prompt-for.html
Take a look at this link.
Pass parameters to a stored procedure in a Crystal Report sub report?
Here are two other links that could prove helpful as well.
passing parameters in crystal report
http://www.tek-tips.com/faqs.cfm?fid=1329
We had the same issue and resolved this by modifying our code that prints the report.
Instead of setting the ReportSource of the CrystalReportViewer before setting the report parameters, set it after you have added all the report and subreport parameters.
I just solved it with something very simple, I don`t know if it works in every case but in my case it did.
Solution:
Go to Properties of your CrystalReportViewer and set ReportSource=None
Use following steps
Don't use CrystalReportViewer1.RefreshReport or CrystalReportViewer1.Refresh
Set Report source from properties to none
Report source must be assigned Dynamically
in your code have this sequence
REPORT1.Refresh()
REPORT1.SetParameterValue(0, "some default value") 'assign some default value
CrystalReportViewer1.ReportSource = REPORT1 'dynamically assigned report source