VB 6.0 - vb6 & crystal report - Asked By Monali Lonkar on 11-Sep-05 01:05 AM

i want the excat code with example, to pass values to a stored procedure and then generate crystal report8 based on that values from vb6

hi monali, try this - Asked By Venkat K on 11-Sep-05 07:45 AM

Crystal Reports Viewer Control
Crystal Reports ActiveX Designer Run Time Library

' Typical Variable Declarations
dim crApp as CRAXDRT.Application
dim crRept as CRAXDRT.Report
dim crParamDefs as CRAXDRT.ParameterFieldDefinitions
dim crParamDef as CRAXDRT.ParameterFieldDefiniton
dim crDBTab as CRAXDRT.DatabaseTable

' Open Report File
set crRept = crApp.OpenReport("WHATEVER.RPT")

' Logon to SQL server
crRept.Database.LogonServer "p2ssql.dll", "server name", "database name", "userid", "userpassword"

' Set table locations (because my reports run against multiple servers)
foreach crDBTab in crRep.Database.Tables
  crDBTab.SetLogonInfo "server name", "database name", "userid", "userpassword"

' Disable Parameter Prompting for the end user
crRep.EnableParameterPrompting = FALSE

' Gather the list of available parameters from the report
set crParamDefs = crRep.ParameterFields

' Loop through all parameters in the report by name, filling in the appropriate parameter with the right value
foreach crParamDef in crParamDefs
  select case crParamDef.ParameterFieldName
    case "SubTitle"
      crParamDef.SetCurrentValue "My Report Subtitle Goes Here"
    case "@BeginDate"
      crParamDef.SetCurrentValue datevalue(txtBeginDate)
    case "@EndDate"
      crParamDef.SetCurrentValue datevalue(txtEndDate)
    case "@IntegerParam"
      crParamDef.SetCurrentValue val(int(txtIntegerParam))
  end select


Hey Rajesh - Asked By J Edmondson on 12-Sep-05 01:37 PM

I am trying to do something similar (pass a selection criteria - which works fine).  All I want to do is print.  Have you ever tried to use crViewer1.PrintReport ?  Or how would you print a report from code (say a Command Button to simply print)?

Thanks for your help.

hi - Asked By Venkat K on 13-Sep-05 12:23 AM

You can print the report directly by calling the PrintReport method, which takes several parameters. If you execute the method with no parameters, a dialog will prompt you for information about the report. The parameters are:

ShowDialog—a Boolean expression that determines whether to display the Print dialog box. The default value, True, causes the dialog to show. 

Range—an integer value that determines which pages to print. The default, rptRangeAllPages (0), causes all pages to print. You can use rptRangeFrom (1) and the next two parameters to specify which pages to print. 

PageFrom—an integer value that determines the first page to print. 

PageTo—an integer value that determines the final page to print.
The object invoked has disconnected - Asked By Venkata Ramana on 20-Sep-05 10:18 AM
While Calling to Crystal Reports from VB6 I am getting Error  like 'Automation Error. The object invoked has disconnected from its clients'. How to rectify this Problme
create crystal reports in vb - Asked By satin mandlik on 24-Sep-05 01:32 AM
please help me
VB 6 0 & crystal reports - Asked By Siddhartha Desarkar on 28-Oct-05 08:06 AM