I am trying to pass the DateTime parameter to crystal from some VB code. The string is formated as "yyyy/mm/dd 12:00:00AM", I have tried many other ways. I really curious how to correctly pass the Date.
What version of Crystal are you using? I am using CR8 and VB6. In CR8 you use the CR8 Automation server to talk to your crystal report from VB. You need to declare the CR8 component in your class module like below.
Global CA As CRPEAuto.Application
Global CR As CRPEAuto.Report
Global DbName As CRPEAuto.Database
Global DbTbls As CRPEAuto.DatabaseTables
Global DbTbl As CRPEAuto.DatabaseTable
Global CrystalParams As CRPEAuto.ParameterFieldDefinitions
Global CrystalParam As CRPEAuto.ParameterFieldDefinition
Global CrystalFormulaFlds As FormulaFieldDefinitions
Global CrystalFormulaFld As CRPEAuto.FormulaFieldDefinition
You need to declare the application ('CA'), report ('CR'),
the database ('DbName'), tables ('DbTbls'), etc.....
The parts of the above your going to use are the formula definitions.
In your report, create a formula with a space between two double quotes like this " ".
You will need to set your application and open your report before being able to pass it data:
Set CA = CreateObject("Crystal.CRPE.Application"
Set CR = CA.OpenReport(strRunReport)
Next set your Database and tables and logon to the server:
Set DbName = CR.Database
Set DbTbls = DbName.Tables
Set DbTbl = DbTbls.Item(1)
Call DbTbl.SetLogOnInfo(my.OraID, "", my.UserID, my.PassWord)
Now scroll through the formulas in your report and set the datetime into the formula's text property.See code below.
Set CrystalFormulaFlds = CR.FormulaFields
For Each CrystalFormulaFld In CrystalFormulaFlds
Select Case CrystalFormulaFld.Name
Case {@YourFormula}
CrystalFormulaFld.Text = VB datetime
End
Next
The report requires 2 DateTime parameters be passed to it. One beginning date and one ending date. I am using Crystal 8 and VB6. My code goes something like this:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.