Click to See Complete Forum and Search --> : Beginner - Help needed in parameter passing
meenasrs
June 13th, 2005, 02:35 AM
Hello,
I want to pass the parameter from VB6 to crystal report to get the reports. I want to pass the string and date parameters. I tried. But, I am getting errors. Pl. help and give the syntax for passing (both the types of parameters).
Madhi
June 13th, 2005, 03:18 AM
To pass a string
Cr.Parameter(0)='" & string & "'
To pass a Date
Cr.Parameter(0)=#" & date & "#
meenasrs
June 13th, 2005, 10:52 AM
When passing parameters like the one you give, it shows syntax error (expecting expression) during the run time. Is anything has to be done in CR?
Madhi
June 13th, 2005, 10:57 AM
Which version of CR you are using?
meenasrs
June 14th, 2005, 03:06 AM
CR version 8.5. VB 6 - Actually there is no "parameter" property. I selected parameter field property. It shows the syntax error. When parameter alone is given it shows "missing expression" error. Pl. help .
Meenakshi.R
meenasrs
June 17th, 2005, 12:01 PM
Pl. help me in parameter passing. I used the following code
crystalreport1.selectionformula="{servmst.mrtcd}=' "&wmrtcd&" ' "
by following a book I referred. wmrtcd is the variable I assigned to get the value at run time. But the code shows the error message 'Syntax error'. Pl. help me in completion of my project
Madhi
June 18th, 2005, 12:18 AM
What is the datatype of mrtcd?
If it is numeric, then
crystalreport1.selectionformula="{servmst.mrtcd}= "&val(wmrtcd)&""
meenasrs
June 20th, 2005, 10:10 PM
wmrtcd is a string value. I typed like this
CrystalReport1.SelectionFormula = "{servmst.mrtcd}= "&wmrtcd&""
It shows syntax error.
meenasrs
June 27th, 2005, 09:31 AM
Anybody Pl. help me in parameter passing.
Madhi
July 2nd, 2005, 08:25 AM
How about using Selection formula from the menu?
Open the report goto Report->Selection Formulas->Record
then write this code
{servmst.mrtcd}= parametername
meenasrs
July 21st, 2005, 12:19 PM
Sir,
I wrote the code as you given. But whenever I select the parameter from the VB code it displays the first record only. What to do? But I am selecting some other record. Here I have listed the code I used. Pl. guide me
Private Sub Cmd_run_Click()
MsgBox wmrtcd
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.Action = 1
With the message box, I can get the parameter I selected.
tks_muthu
July 22nd, 2005, 06:15 AM
Hi!
plz try this format
String :
---------
wmrtcd="{emp_det.emp_id} = '"& trim(your_id) &"'"
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
Numeric :
-----------
wmrtcd="{emp_det.emp_id} = "& trim(your_id) &""
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
Date :
-------
Dim da, str As Variant
Dim a, b, c, e As Variant
da=cdate(rsEmp.fields("emp_det.emp_doj").value)
a = Day(da.Value)
b = Month(da.Value)
c = Year(da.Value)
d = "#" & c & "/" & b & "/" & a & "#"
wmrtcd="{emp_det.emp_doj} = '"& d &"'"
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
note : crystal report date format is "YYYY/MM/DD"
meenasrs
July 26th, 2005, 10:25 AM
Hi,
I can't understand what is "your_id". But I tried this code
MsgBox wmrtcd
wmrtcd = "{servmst.mrtcd} = '" & Trim(wmrtcd) & "'"
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 1
It shows the following error.
Run Time error '20515'
Error in file f:\meena\project\test\sermst.rpt
Error in formula <Record_Selection>
' The remaining text does not appear to be part of the formula.
What to do? Pl. help me.
Madhi
July 26th, 2005, 10:42 AM
Make sure you have given the correct column name
tks_muthu
July 28th, 2005, 05:26 AM
Hi!
Its a Parameter Value.
EmpID='ii-0406'
EmpSal=6000
EmpDoj="13/09/2004"
String :
---------
wmrtcd="{emp_det.emp_id} = '"& trim(EmpID) &"'"
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
Numeric :
-----------
wmrtcd="{emp_det.emp_id} = "& trim(EmpSal) &""
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
Date :
-------
Dim da, str As Variant
Dim a, b, c, e As Variant
da=cdate(EmpDoj)
a = Day(da.Value)
b = Month(da.Value)
c = Year(da.Value)
d = "#" & c & "/" & b & "/" & a & "#"
wmrtcd="{emp_det.emp_doj} = '"& d &"'"
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wmrtcd
CrystalReport1.Action = 2
meenasrs
July 28th, 2005, 12:27 PM
Hai,
I tried with the following code.
MsgBox wmrtcd
wsel = "{servmst.mrtcd} = '" & Trim(wmrtcd) & "'"
MsgBox wsel
CrystalReport1.ReportFileName = "f:\meena\project\test\sermrtcd.rpt"
CrystalReport1.SelectionFormula = wsel
But still gets the same error. With the mesg box it shows
servmst.mrtcd='A001'
When debugging the error, it shows
wsel = "{servmst.mrtcd}='A001'" (when mouse is dragged over the line.
Pl. help me from coming out of this problem.
Regards
tks_muthu
July 29th, 2005, 04:25 AM
Hi! see this link
http://support.businessobjects.com/library/kbase/articles/c2010935.asp
else
plz try to add the report as dsr.
1) Visual Basic -->Project Explorere-->Add-->More ActiveXdesigner-->Crystal Reports8.5
then customize ur report as u like.
i am attaching a sample report here plz see this.
regards
muthu
meenasrs
August 4th, 2005, 12:29 PM
Hai,
I have included that crystal report using designer. But how to name the object "Crystal viewer". In the sample code it is written as crviewer1. I have tried with crystalviewer, crviewer. But whatever I type it shows " No object". Pl. help.
Regards
meenasrs
August 7th, 2005, 10:12 AM
Help me in completion of the project
Madhi
August 8th, 2005, 12:44 AM
You need to use Crystal Viewer and use that name in the code
tks_muthu
November 24th, 2005, 01:45 AM
Hi! see this link
http://support.businessobjects.com/library/kbase/articles/c2010935.asp
else
plz try to add the report as dsr.
1) Visual Basic -->Project Explorere-->Add-->More ActiveXdesigner-->Crystal Reports8.5
then customize ur report as u like.
i am attaching a sample report here plz see this.
regards
muthu
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.