Pasar Parametros en crystal report 8.5
Publicado por beto (1 intervención) el 26/09/2006 18:21:02
hola necesito ayuda urgente y la eh buscado espero me puedan ayudar...necesito pasar 2 parametros a mi reporte cr8.5 q funciona correctamente en cr pero cuando lo envio de vb6 me sale el reporte en blanco supongo q no recibe los parametros este es el codigo q utilice (utilizo el crviewer) si me pueden ayudar mandenmelo a este msn [email protected]
=====boton===============
On Error GoTo P:
Dim col As Collection
FECHAINI = Format(DTFECHAINI.Value, "DD/MM/YYYY")
FECHAFIN = Format(DTFECHAFIN.Value, "DD/MM/YYYY")
Set col = New Collection
col.Add FECHAINI, "FECHAINI"
col.Add FECHAFIN, "FECHAFIN"
Dim frmRpt As frmReportes
DoEvents
Set frmRpt = New frmReportes
frmRpt.Tag = "LISTADO DE RANKING DE VENTAS"
DoEvents
frmRpt.CargaReporte App.Path & "\Reportes\RPT_RANKING_VENTAS.rpt", col
P:
If err.Number = 0 Then
Else
MsgBox err.Description, vbCritical, Me.Caption
End If
===frmReportes====================
Option Explicit
Public Sub CargaReporte(ByVal ReportFileName As String, ByVal Parameters As Collection)
On Error GoTo err:
Dim crApp As CRAXDRT.Application
Dim crRept As CRAXDRT.Report
Dim crDBTab As CRAXDRT.DatabaseTable
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
Dim X As Integer
Set crApp = New CRAXDRT.Application
Set crRept = crApp.OpenReport(ReportFileName)
crRept.EnableParameterPrompting = False
crRept.DiscardSavedData 'ESTA LINEA ES PARA ACTUALIZAR LOS DATOS DEL REPORTE
' crRept.Database.LogOnServer "p2sodbc.dll", "(local)", "CALVORS", "sa", ""
Set crParamDefs = crRept.ParameterFields
' Loop through all parameters in the report by name, filling in the appropriate parameter with the right value
X = 1
On Error Resume Next
For Each crParamDef In crParamDefs
'Aqui detectamos si en el objeto collection Parameters existe el parámetro o no
Parameters (crParamDef.ParameterFieldName)
If err.Number = 0 Then
crParamDef.SetCurrentValue Parameters(crParamDef.ParameterFieldName)
End If
Next
On Error GoTo 0
'**********ver
Me.Caption = IIf(Len(Me.Tag) > 0, Me.Tag, crRept.ReportTitle)
' CRViewer1.Refresh
CRViewer1.ReportSource = crRept
crRept.VerifyOnEveryPrint = True
CRViewer1.DisplayGroupTree = False
CRViewer1.EnableExportButton = True
CRViewer1.ViewReport
CRViewer1.Zoom 110
Exit Sub
err:
MsgBox err.Description, vbCritical, "Error..."
End Sub
Private Sub cmdExit_Click()
If Not CRViewer1.IsBusy Then
Unload Me
End If
End Sub
Private Sub CRViewer1_CloseButtonClicked(UseDefault As Boolean)
CRViewer1.PrintReport
End Sub
Private Sub Form_Activate()
FRMCERO Me
End Sub
Private Sub Form_Load()
CRViewer1.EnableRefreshButton = False
End Sub
Private Sub Form_Resize()
On Error Resume Next
CRViewer1.Height = Me.Height
CRViewer1.Width = Me.Width
cmdExit.Move Me.ScaleWidth - cmdExit.Width - 430
End Sub
=====boton===============
On Error GoTo P:
Dim col As Collection
FECHAINI = Format(DTFECHAINI.Value, "DD/MM/YYYY")
FECHAFIN = Format(DTFECHAFIN.Value, "DD/MM/YYYY")
Set col = New Collection
col.Add FECHAINI, "FECHAINI"
col.Add FECHAFIN, "FECHAFIN"
Dim frmRpt As frmReportes
DoEvents
Set frmRpt = New frmReportes
frmRpt.Tag = "LISTADO DE RANKING DE VENTAS"
DoEvents
frmRpt.CargaReporte App.Path & "\Reportes\RPT_RANKING_VENTAS.rpt", col
P:
If err.Number = 0 Then
Else
MsgBox err.Description, vbCritical, Me.Caption
End If
===frmReportes====================
Option Explicit
Public Sub CargaReporte(ByVal ReportFileName As String, ByVal Parameters As Collection)
On Error GoTo err:
Dim crApp As CRAXDRT.Application
Dim crRept As CRAXDRT.Report
Dim crDBTab As CRAXDRT.DatabaseTable
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
Dim X As Integer
Set crApp = New CRAXDRT.Application
Set crRept = crApp.OpenReport(ReportFileName)
crRept.EnableParameterPrompting = False
crRept.DiscardSavedData 'ESTA LINEA ES PARA ACTUALIZAR LOS DATOS DEL REPORTE
' crRept.Database.LogOnServer "p2sodbc.dll", "(local)", "CALVORS", "sa", ""
Set crParamDefs = crRept.ParameterFields
' Loop through all parameters in the report by name, filling in the appropriate parameter with the right value
X = 1
On Error Resume Next
For Each crParamDef In crParamDefs
'Aqui detectamos si en el objeto collection Parameters existe el parámetro o no
Parameters (crParamDef.ParameterFieldName)
If err.Number = 0 Then
crParamDef.SetCurrentValue Parameters(crParamDef.ParameterFieldName)
End If
Next
On Error GoTo 0
'**********ver
Me.Caption = IIf(Len(Me.Tag) > 0, Me.Tag, crRept.ReportTitle)
' CRViewer1.Refresh
CRViewer1.ReportSource = crRept
crRept.VerifyOnEveryPrint = True
CRViewer1.DisplayGroupTree = False
CRViewer1.EnableExportButton = True
CRViewer1.ViewReport
CRViewer1.Zoom 110
Exit Sub
err:
MsgBox err.Description, vbCritical, "Error..."
End Sub
Private Sub cmdExit_Click()
If Not CRViewer1.IsBusy Then
Unload Me
End If
End Sub
Private Sub CRViewer1_CloseButtonClicked(UseDefault As Boolean)
CRViewer1.PrintReport
End Sub
Private Sub Form_Activate()
FRMCERO Me
End Sub
Private Sub Form_Load()
CRViewer1.EnableRefreshButton = False
End Sub
Private Sub Form_Resize()
On Error Resume Next
CRViewer1.Height = Me.Height
CRViewer1.Width = Me.Width
cmdExit.Move Me.ScaleWidth - cmdExit.Width - 430
End Sub
Valora esta pregunta
0