Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/07/2007, 11:10
ci2000
 
Fecha de Ingreso: abril-2005
Mensajes: 483
Antigüedad: 20 años
Puntos: 3
Re: Crystal Report y parámetros

En el formulario desde dónde paso los parámetros hago esto:

Código:
  TitReporte = "Listado de recibos"
  ArcReporte = "listadorecibos.rpt"
  FoReporte.PasarParametros DTDesde, DTHasta
  FoReporte.Show
Y esto está en el formulario del reporte:

Código:
Option Explicit

Private crApp As New CRAXDRT.Application
Private crReport As New CRAXDRT.Report
Private Parametro1 As Date
Private Parametro2 As Date

Private Sub Form_Load()
    Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
    Dim crParamDef As CRAXDRT.ParameterFieldDefinition

    FoReporte.Caption = TitReporte
    Screen.MousePointer = vbHourglass
    Set crReport = crApp.OpenReport(App.Path & "\" & ArcReporte, 1)
    
    ' Parametros del reporte
    Set crParamDefs = crReport.ParameterFields
    For Each crParamDef In crParamDefs
        Select Case crParamDef.ParameterFieldName
            Case "parametro1"
                crParamDef.AddDefaultValue (Parametro1)
            Case "parametro2"
                crParamDef.AddDefaultValue (Parametro2)
        End Select
    Next
    
    CRViewer.ReportSource = crReport
    CRViewer.DisplayGroupTree = False
    crReport.DiscardSavedData
    CRViewer.ViewReport
    Screen.MousePointer = vbDefault
    Set crParamDefs = Nothing

    Set crParamDef = Nothing
    
End Sub

Private Sub Form_Resize()
    CRViewer.Top = 0
    CRViewer.Left = 0
    CRViewer.Height = ScaleHeight
    CRViewer.Width = ScaleWidth
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set crReport = Nothing
    Set crApp = Nothing
End Sub

Public Sub PasarParametros(sParam1 As Date, lParam2 As Date)
    Parametro1 = sParam1
    Parametro2 = lParam2
End Sub

En el archivo .rpt tengo creado dos campos parametro1 y parametro2 de tipo Date.

Saludos