Friday, March 23, 2012

how can i pass values from .mdb to crystal report?

how can i pass values from a text box to crystal report.the value is not stored in the database.please help me...Pass it as a parameter.

Create a parameter field in the report.

Then pass the value for the parameter from ur interface to report in the folg. way

Cr1.ParameterFields.GetItemByName("EnterOption").AddCurrentValue(ParamOption)

Here EnterOption is the name of the parameter created in Crystal Reports and ParamOption contains some value which u want to pass (any value)

Hope this may help|||Thanks ,
But its not working.I got an error message like this "Argument not optional". Pls explain the reason and do help me with sample code
Thanks
Hari|||Hope you are using VB code for creating interface
--------

'In the General Declarations , declare

Dim Appl As New CRAXDRT.Application
Dim Report As New CRAXDRT.Report

'Assinging the report name
Set Report = Appl.OpenReport("report1.rpt")
Report.DiscardSavedData
'Passing the value of cmboption.Text value to the first parameter
'instead of passing by the name of the parameter, we can also use this convention
Report.ParameterFields(1).AddCurrentValue cmbOption.Text

'Assigning the report source to CRViewer Control and viewing the report
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

--------

If your code produces error, send the code fragment|||There are 3 ways to deal with this/your problem or setting/passing arguments to a report :

Sample 1
---
g_ole_crx_report.DiscardSavedData()
g_ole_crx_report.ParameterFields.item[1].AddCurrentValue("100200300")

Sample 2
---
g_ole_crx_report.DiscardSavedData()
g_ole_crx_report.ParameterFields[1].AddCurrentValue("100200300")

Sample 3
---
g_ole_crx_report.DiscardSavedData()
g_ole_crx_report.ParameterFields.GetItemByName("@.AccountNumber").AddCurrentValue("100200300")

Sample 4
---
g_ole_crx_report.DiscardSavedData()
g_ole_crx_report.ParameterFields.item[3].AddCurrentValue(date("01/01/1999"))

Look at this sample. It needs conversion. You need to use convert function like date (I dont' know about VB) to convert date to date format.

Maybe this is what causing your problem.

Thanks

No comments:

Post a Comment