Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Set Parameter Values To Crystal Report At Runtime

Set Parameter values to crystal report at runtime ...?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Modify Field Values In Crystal Report At Runtime

I have this simple question. I have a report in the designer section of my ide with fields that match fields in my db. How can I instead of showing the actual values in the db for certain fileds, modify them before display by passing these values in a function then display the results?

Any help anyone? Thanks very much.

What's Logon Parameter To Oracle Server With Vb To Print Report With Crystal Report
Hi all,

How to write a log on parameter to oralce server with using vb to print a report that using crystal report

is it crystalreport1.connect = "Dsn=servername;uid=username;pwd=password"

and how to use the selectionformula

Live Parameter Values For Crystal Reports 8.5???
I'm not sure if this is the right group for this posting, so I apologize in advance if I'm in the wrong group.

I'm wondering if there is any way to get my parameter default values to dynamically get values from my database when I run my report. The values that I need to select change quite often. Thanks in advance...

Passing Report Parameter Values
Hi there,

i have designed a report in Crystal repots using Sql Server Stored procedure. i need to pass the parameter value's to the report thru VB.

I tried CrystalReport1.ParameterFields(0) = "fromDate=date(2001,11,1)"
but it gives a error Invalid formula name , i tried attaching {@fromdate} ,{?@fromDate} still the same error creeps up..

Did anyone tried similar thing?.

Your help is appreciated.


Crystal Question...populating Parameter Field Values?
In my VB6 app I have a Crystal Report DSR file that shows employee's clock in time. Well one of my parameter fields (which is called EmployeeName) is part of my main record selection. So it pops up on the screen everytime you hit the refresh button on the report. Right now there is a drop down showing all the employee names for the user to select. However this is only a one time deal, if a new employee gets added to the database he/she wont be updated in this list. How can I fix this?

Parameter In Crystal Report
I am a newcomer in Crystal report. I want to create a report which take a parameter of type date. And all the records of that date should be displayed. The date should be pass from VB6. I dont have any idea of how to do it?
Any help will be appreciated.


Parameter In Crystal Report 9
Does anybody have idea how I can get parameter in Crystal report (in Visual Basic 6 application ) from signed variable from module in application.

I want to have one text field on the top of report where will be date which is equel the date from variable in module.

This is my variable in module:

Public myDate As Date

I have error if I sign this under Report_Initialize ...

Text15.Text = myDate

Crystal Report Parameter

How can I make sure that my Command SQL inside the Crystal Report can read parameter values.

This is how I've got it:
SELECT * FROM Students WHERE stu_num = '{?stu_num}'

I get a blank report though I'm sending parameters correctly.

Crystal Report - Parameter - Please Help
How do I pass a value from a Text Box to Crystal Report. I am using Crystal Report Version 4.6. I could not find any parameter field. Please help me.

Crystal Report Parameter
How can I pass a value from VB to Crystal Report.


Parameter Value To Crystal Report

I am calling crystal report from vb6.0, I accept some fields on screen who can i pass these field crystal report for check.
who it will be define in crystal report.

Thanks in advance


Passing Parameter To Crystal Report
I want to ask you How can I pass a parameter field to crystal report from Visual Basic 6 ????
I am using the Crystal Report Viewer .

Thank you very much!!!!

How To Pass Parameter Value From Vb To Crystal Report?
how to pass parameter value from vb to crystal report?

Passing A Parameter To Crystal Report
Hello Everyone! I'm new to crystal reports and I want to make an inventory that could pass a parameter to a crystal report. Could you guys help me how to do it? I just need a few simple examples on how to start. Any help will be greatly appreciated. Thanks and god bless!

Crystal Report Parameter Field
Now I've been searching to this forum and Google and found no luck....
I have this crystal report , just named it : report.rpt
and this report got three parameters field that needed to select the record to access the database , namely : prompt0,prompt1,prompt2.
How do I pass the value from the textbox to this parameter field in the report?

I use vb6 and cr 8.5
And I use the activeX Crystal Report in the VB application.

Here is my code :

CrystalReport1.ParameterFields(0) = "prompt0;" + "01" + ";true"
CrystalReport1.ParameterFields(1) = "prompt1;" + " & txtNumber & " + ";true"
CrystalReport1.ParameterFields(2) = "prompt2;" + " & txtNumber & " + ";true"
CrystalReport1.Connect = "DSN=AURORA;UID=UID;PWD=PWD"
CrystalReport1.Action = 1

Everytime I run the code , it gives me the same error code :
"Invalid parameter field value"
When I use the "Val(txtNumber)" , it didn't help.
Please help me.
Thx in advance....

Crystal Report Parameter Problem
Hello everyone. I have this problem in Crystal Report specifically in parameter passing. The report is a Collection Report. Once i chose a month and year, it automatically sets the dateto value four months ahead of the chosen date. So assuming i chose jan and 2004, the range will be jan 1, 2004 to may 31, 2004. But once i use dec for example the range exceeds 1 month as intended. So what appears is dec 1 2004 to may 31, 2004, i cant trace the problem becuase i checked the parameter that i pass and its april 2004 not may 2004.
Here is a segment of my code.

DateFrom = Year(dtYear) & "-" & Month(dtMonth.Value) & "-" & 1
Select Case (Month(dtMonth) + 4)

Case 13
preMonth = 1
preYear = Year(dtYear) + 1
Case 14
preMonth = 2
preYear = Year(dtYear) + 1
Case 15
preMonth = 3
preYear = Year(dtYear) + 1
Case 16
preMonth = 4
preYear = Year(dtYear) + 1
Case Else
preMonth = Month(dtMonth) + 4
MsgBox preMonth
preYear = Year(dtYear.Value)
End Select

MnthEnd2 = Day(EndOfMonth(CDate(preMonth & "/" & 1 & "/" & preYear)))
DateTo = CDate(preYear & "-" & preMonth & "-" & MnthEnd2)

Set crpParamDefs = Rpt.ParameterFields

For Each crpParamDef In crpParamDefs
With crpParamDef
Select Case .ParameterFieldName
Case "@dtFrom"
.SetCurrentValue CDate(DateFrom)
Case "@dtTo"
.SetCurrentValue CDate(DateTo)
End Select
End With

' i used this function to be able to get the last day of the month
Function EndOfMonth(ByVal D As Date)
EndOfMonth = DateSerial(Year(D), Month(D) + 1, 0)
End Function

Help Please.....Thanks

To Pass Parameter From Vb6 To Crystal Report
Hello Friends,

My problem is I want to accept value from user which I am nt storing in databasse. I am using inputbox to get value from user and then I want to print the same value in the crystal report. I am not using crystal report viewer, but I've used crstyal report's ocx and from there i am opening report by using printreport method of the crystal report's ocx control. plz help me.

below is my code which i m using to print report

VB Code:
With crStudList        .Connect = strConn        .ReportFileName = App.Path & "
eportsStudentList.rpt"        .ReportTitle = "Student List"        .WindowTitle = "Student List"        '.SelectionFormula = "{tblStudent.RegistrationDate}>= DateValue (" & dtpFrom.Value & ") and {tblStudent.RegistrationDate}<= DateValue(" & dtpTo.Value & ")"        .SelectionFormula = "{tblStudent.RegistrationDate}>=#" & Format(dStartDate, "dd/MM/yyyy") & "# and {tblStudent.RegistrationDate}<=#" & dEndDate & "#"                .Destination = crptToPrinter        .PrintReport     End With

where crStudList the name of ocx control of crystal report


Crystal Report - Passing Parameter

please tell me the syntax of SetReportVariableValue in crystal report. I am getting Run-time error '70' permission denied when I try this. any other way to pass parameter to the report? (I'm using CR 9 with VB 6)

Thanks in advance!


Passing Parameter To A Crystal Report
i'm using vb6 and crystal reports 8.5. i have a string value that i need to pass to my rpt. here is the sample of my code:

Set CRReport = New CRAXDRT.Report
Set CrxApp = CreateObject("CrystalRunTime.Application")
Set CRReport = CrxApp.OpenReport(vstrReportFile)
CRReport.Database.SetDataSource vPassedADORS, 3, 1
CRViewer1.ReportSource = CRReport
CRReport.ParameterFields(0) = " Par1;" + vstrParameters + " ;true"
CRReport.PrintOut False, 1, True

when i run this code i get the error subscript out of range.

when i create another project that uses the crystal report component i use the following code:

cry1.ParameterFields(0) = " Par1;" + vstrParameters + " ;true"

it works fine.

can any one help?

Thank You,

Discrete Value In Parameter (crystal Report)
I am using VB6.0 & access as backend.
I am making one report which will print salesmanwise sales. I want to give option to the user to select the salesman & accordingly the sales will get generated. For that I have used parameter option, in that I have selected the table & in field I have selected salesman.

So far so good, The report is giving what I want, but when I add new Salesman to the table and I generate the report again, It is not showing the newly created salesman in the discrete value, any idea.
Is there any refresh Or like that ?



How VB Pass Parameter To Crystal Report
how to pass Parameter to Seagate Crystal report by VB?

I want to pass One or More parameter to Crystal report to meet a certain critera

like i want to select some record by my application given date so report should be contains only those record sort by given date.

Parameter Passing In Crystal Report
I have designed a report in Crystal report 7.0 and wanted to view it thru VB6.0 application. I am using crystal report control. When I refresh my report from crystal report and enter a specific date the report generates for that date but when I refresh it from my VB application and enter any date its not giving anything. Do I need to set some property or something else. please help me. its very urgent.


Passing Parameter To Crystal Report
i'm using the CRViewer to view my report. i found out i cannot pass in Date into crystal report from VB. any one can give me help?

sample code:
CrxReport.ParameterFields(1).AddCurrentValue (format(now,"dd/mm/yyyy"))

the parameter in crystal report defined as Date.


Parameter Problem In Crystal Report 8.5?
i have problem in parameter using CR 8.5, when i input the name in preparedby text box i want the parameter to directly out put in crystal report. how can i do that?
pls see attached pictures.

Private Sub cmdPrint_Click()
'on error goto err_handler

Dim strsqlstring As String
Dim strparam1 As String
Dim strparam2 As String

If Opt1.Value = True Then
   If DTPicker1.Value <> "" And DTPicker2.Value <> "" Then
      strsqlstring = "{tbltallyreceipts.dtdate} >= #" & Format(DTPicker1.Value, "mm/dd/yyyy") & "# and {tbltallyreceipts.dtdate} <= #" & Format(DTPicker2.Value, "mm/dd/yyyy") & "# And {tbltallyreceipts.st_services} = '" & cboPrintServices & "'"
      strparam1 = frmPrint.txtpreparedby
      strparam2 = frmPrint.txtnotedby
   End If
  With CrystalReport1
     .ReportFileName = App.Path & "fdata.rpt"
     .Connect = App.Path & "financialdata.mdb"
     .DiscardSavedData = True
     .ReportSource = 0
     .SQLQuery = "Select *from tbltallyreceipts "
     .WindowTitle = "Financial Data"
     .ReportTitle = "Total Receipts"
     .Destination = crptToWindow
     .PrintFileType = crptCrystal
     .WindowState = crptMaximized
     .WindowMaxButton = False
     .WindowMinButton = False
     .SelectionFormula = strsqlstring
     .ParameterFields(0) = "prpreparedby;" & strparam1 & ";false"
     .ParameterFields(1) = "prnotedby;" & strparam2 & ";false"
     .Action = 1
  End With
     frmPrint.txtnotedby = ""
     frmPrint.txtpreparedby = ""
End If


End Sub

How To Pass A Parameter In Vb Using Crystal Report 9.0

      i'm using vb 6.0 , access 98 & cr 9.0. plz help me how to pass a parameter using vb 6.0 .
in run time.


vikramjb : post moved to the reporting section. Please post in the approriate forums.

Edited by - vikramjb on 12/22/2005 2:08:48 AM

Textbox Parameter In Crystal Report
Can someone show me how to pass a textbox value from vb .net to crystal report?

How can i refresh the report if i change the value in the textbox?


Parameter Passing In Crystal Report
I am passing parameters to report ,but it is giveing me error "invalid Field ".
do each field have any specific index,or number in the report .I have designed the report already.

Discrete Value In Parameter (crystal Report)
I am using VB6.0 & access as backend.
I am making one report which will print salesmanwise sales. I want to give option to the user to select the salesman & accordingly the sales will get generated. For that I have used parameter option, in that I have selected the table & in field I have selected salesman.

So far so good, The report is giving what I want, but when I add new Salesman to the table and I generate the report again, It is not showing the newly created salesman in the discrete value, any idea.
Is there any refresh Or like that ?



Pass Parameter To Crystal Report
i need to pass a parameter to crystal report from a listview in vb6. i wan the report to populate only 1 record. possible?

Null Parameter In Crystal Report Help?
Hay i want explain the report first
i have report get data from table ad also i have 5 parameters .
my question is:
How i can make the report when the parameters enter he get only record how meet these conditions and if the paramters null he get all data also if i enter two or three parameters he get the data whos meet these values

is there any way?

How To Pass The Parameter To Crystal Report?
How to pass the parameter to crystal report ?
how to pass the parameter to data report?


Passing Parameter In VB6 To Crystal Report
Hi Babu,
I used code that you gave me but there is a error "205539 :Invalid parameter field name".Can you show me clearly? Thanks in advance!

Passing Parameter To Crystal Report
i am passing a string value from vb code to crystal report. in crystal report i have created this parameter as "Pyyyymm" receiving string value.

the vb code goes like this

report1.parameterfields(0) = "Pyyyymm;" & m_SelSalMnth & ";true"

where m_SelSalMnth contains '2002/10' or like value but it gives me error "can't find SQL Server" and error no. 20599.

i don't know where i am going wrong.

i am adding crystal report thru component and not thru reference i.e. i am using a crystal report control.

Waiting for a quick reply.


Crystal Report Parameter Field
SurrenderMonkey (thanks a lot, man!) find it out how to make those parameter fileds work in VB code:
'A simply report with one parameter field
'Matter is to pass a parameter value to a rpt file
'through Ocx - or: to make parameter fields to be filled
'via code form VB.
Cr1.ReportFileName = "D:CondivisaCesarevbCrystolcrywebReport1.rpt"
Cr1.ReportSource = 0
Cr1.DiscardSavedData = True
Cr1.ParameterFields(0) = "SelectMe;1;false" 'parameter field name={?SelectMe}
'second value is value you want the parameterto gain by default, third
'should 'make it work silently, but it does not work properly: a window appear,
'asking for value. Only if you click on OK button ypu will see your report
Cr1.Action = 1 'make it print

'I posted it here as I think it should be of interest. And if anybody finds out
'how to make this really silent, please tell!

Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.

Problem Passing Parameter IN Crystal Report From Vb 6.0
WEll hi to all

I am new user here.........I really need help in my project

My problem is that i have made a project in Vb6.0 and database in Ms Access

Now i make report in Crystal report 9 and by using Wizard Expert

now what i want to do is i want to pass parameter by using my own design
form in Vb6.0 like i want to pass account no so it will display only the result of that account no i don't know that code exactly and please tell me do i need to use parameter option in crystal report or just pass parameter from Vb from

i will really thankful to those people who help me out in this regard

Sorry for poor english

Parameter Based Recordset In Crystal Report

I am using crystal 8.5 with VB6 and MS Access. I have made a .rpt file and using a recordset i am able to see the report populated with those records from recordset properly.
Now i want to make use of parameter fields so that user will be prompted for it and once he selects / enters the parameter the report should be populated with those records only.The user will be asked for 2 parameters - 1) Date and 2)Number and then the recordset should be based on these 2 parameters . I have created these 2 parameters in .rpt file but dont know how to use them in my "SELECT" query ... Any help ?


How Do I Pass A Parameter Range To A Crystal Report (v8.5)?

I am using VB6 and Crystal 8.5 (the database is only compatible with this version of Crystal.

I need to pass a parameter range to my VB code, the parameter works fine in Crystal, but I cannot work out how to pass the parameter range in code.

All help very welcome!


Blinking Nora

How To Pass Parameter Using Crystal Report Viewer
I have a report to which i am passing a parameter value custid
i was earlier using just the rdc control and showing the report and passing the parameter by

CrystalReport1.ParameterFields(0) = "custid;" & Combo2.Text & ";true"

now when i use crystal viewer using the foll. code

Dim app1 As CRAXDRT.Application
Dim rep As CRAXDRT.Report

Private Sub Form_Load()

Set app1 = New CRAXDRT.Application
Set rep = app1.OpenReport("c:sales1.rpt", 1)

With Form1
.CRViewer1.ReportSource = rep
End With
End Sub

the report prompts for a parameter

How can i pass the parameter to the report within this code so that the viewer does not prompt for any input
thanks in advance

Passing The Parameter To Crystal Report Using ParameterFieldDefinitions
Hi everyone,

I am get the error in assigning the value to the parameter of parameter1 in crystal reports. It is the string parameter type .I tried with setcurrentvalue and also addcurrentvalue mothod. But i can't able to pass the parameter.

Even though i am using
crRepp.EnableParameterPrompting = False
it prompting for the parameters values......

CrystalReport1 is ICRDesigner object

Dim Report As New CrystalReport1
Private Sub Form_Load()
Dim crApp As New CRAXDRT.Application
Dim crRepp As CRAXDRT.Report
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
Dim crDBTab As CRAXDRT.DatabaseTable

'Open report file
Set crRepp = crApp.OpenReport(App.Path & "ReportTest.rpt")
'Set location of database based on WhatCompany

crRepp.Database.LogOnServer "p2sodbc.dll", "Testpass", "Northwind", "sa", ""
'Set table location to appropriate company server

For Each crDBTab In crRepp.Database.Tables
crDBTab.SetLogOnInfo "Testpass", "Northwind", "sa", ""
crRepp.DisplayProgressDialog = False
crRepp.EnableParameterPrompting = False

'Fill report parameters
Set crParamDefs = crRepp.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "Parameter1"
crParamDef.AddCurrentValue "eeeeee"
End Select


Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
Screen.MousePointer = vbDefault
End Sub

pls help me to come out the problem
Advance thanks


Pass BLOB Parameter To Crystal Report
I would like to display the image from the local file system where I can pass the path or the whole image (in BLOB fieldType). But I found that I cannot set the parameter field type into BLOB (only can set String, Date, Time, etc). What can I do? I found that it works when the photo is stored in database only. Is there anybody can solve this problem?

Problen In Crystal Report 8 On Parameter Passing
Dear Group Members

Need some help !

I have created a crystal report 8 name as Report1.rpt, I have alsoinserted a parameter field as NAM in this report, Than I have createda form in Vb6 and put a command button on this form and the code haswritten on this command event as

CrystalReport1.ReportFileName = "C:engg
CrystalReport1.ParameterFields(1) = "NAM;INDORAMA;TRUE"
CrystalReport1.Action = 1

The backend is oracle and have aslo setted the Odbc as Cror7 or Cror8

When I run this form and click on command button then a erroroccurs like

Run time error 20599
Can not open sql server

If I not use the parameter field NAM then this for is work properly

I am not getting that I am not using the Sql server then why it isdisplaying this error

I will be highly oblige if any one will send the solution at earliest


Dk Varshney

Passing Parameter To Crystal Report (SubReport)
  I have a report and subreport in crystal report. I am able to pass parameter to report but it doesn't work for subreport. I am not sure if there is any method available for this purpose. Any help would appreciate?

Here is my code to passing information to main report

CrxReport.ParameterFields.GetItemByName("SectionName").AddCurrentValue "Business - Solution"
I try to use the same mothod for passing DATE to subreport but I was not successful

Store Procedure Parameter In Crystal Report
how can i pass store procedure parameter's in crystal report from VB ?...

i put store procedure in detail section of CR and i need to pass record result from CR to store procedure.

store procedure :
create proc spCredit
@DocumentCode nvarchar(14),
@Documentno nvarchar(14),
@itemcode nvarchar(14)
select sum(qty) from tablename where doccode =@documentcode and docno=@documentno and itemcode =@itemcode group by doccode,docnum,itemcode

in crystal report, detail

document document no product total

doccode docno itemcode spcredit
doc-01 001 ABC 10

can pass parameter of SP for each record resulted by CR ??
in this case passing 'doc-01','001','ABC' to the SP from VB.

Stored Procedure Parameter- Crystal Report
I have created a report in segate crystal report on a stored procedure in SQL7
And I want to change the parameters in runtime without prompting to the user through vb codes. My crystal report object and the parameter field is as shown bellow
m_crwReport.ParameterFields(1) ,and how I can change the value to this parameters
I got syntax from crystal report developers help like
CrystalReport1.ParameterFields(0) = parameter1;red;TRUE

But I don’t know how to give the right hand side ( I mean after the = parameter1;red;true) part of this; my values are Parameter name (@FromDate, “20/03/2003”,True) how can I set this value Please Do any one help me in this regard.

Thanking you

Crystal Report-Stored Procedure Parameter
i m using crystal report 7.0. i am using a stored procedure in the report and i have to pass parameters from vb. the problem i am facing is that whenever i am calling the report from vb, 'Enter Parameter value' dialog box appearing. how can i avoid this dialog box.
also how can i pass date value as a stored procedure parameter?
any one can help me.

Parameter Query In Seagate Crystal Report

I have a query in Seagate Crystal Report 8.0.

I want to add two parameters in crystal report using the ' Create Parameter Field' dialog box.

Parameters are

1. startDate : I want that on running the report, default value for this parameter should be the Monday of the current week.

2. endDate : It's default value should be "Friday of the current week or today, whichever comes first."

Please suggest how to achieve this.

Thanks in advance


Parameter Query In Seagate Crystal Report

I have a query in Seagate Crystal Report 8.0.

I want to add two parameters in crystal report using the ' Create Parameter Field' dialog box.

Parameters are

1. startDate : I want that on running the report, default value for this parameter should be the Monday of the current week.

2. endDate : It's default value should be "Friday of the current week or today, whichever comes first."

Please suggest how to achieve this.

Thanks in advance


Passing Parameter From Text Box To Crystal Report Designer (RDC)
I am new to Crystal Reports. I earlier used Microsoft Data Report but it didnot have the 'Record Number' feature , so I have to re create my reports in Crystal Reports.I am using crystal report 8 designer control ( RDC) for my project on Payroll . I want to create a report which will generate the report based on the month & year.

I have a form containg two combo boxes from where the user will select the month & the year.

I want to pass this to Crystal Report Designer as a parameter.

I used the following query in data report.

select p.empno,e.fname, p.bsal,p.itax,p.netsal,p.mnth,p.yr from emp e, payroll p where e.empno=p.empno and p.mnth= ? and p.yr= ?
order by p.bsal

I used to pass the value for p.mnth & p.yr using the following code in a form which contained the text boxes.

option Explicit

Private Sub Command1_Click()
deConsolidated.Command1 cmbMonth.Text, cmbYear.Text
End Sub


Pls guide me how to pass the parameters from the above combo box to crystal report designer ( RDC)

Thanking you,

**RESOLVED**Crystal Report Date Parameter Problem
I am attempting to set-up a parameter from vb which allows the user to either select a specific date range or select all dates and then run a crystal report based on this parameter.

I have an option button array. If Option2(0).Value = True then the user has opted to select a date range. In which case the from and to dates can be entered into MaskEdBox1 and MaskEdBox2, respectively. If Option2(1).Value = True then the user has chosen to select all dates.

I have a crystal report with 2 Date parameters. {?FromParm} and {?ToParm}.

How do I impose a parameter only when the user has opted to enter a date range? What do I feed the parameter when the user has selected all dates? Should I make parameter a string parameter and convert to a date in the selection formula?

Copyright © 2005-08, All rights reserved