Cita:
Iniciado por vdiaz18
saludos este ejemplo que te envío es para abrir un reporte existente (Crystal Report 9) mediente código, espero te sea util...
Lo primero que debes hacer es habilitar la referencia Crystal Reports Activex Desginer Design and Runtime Library 10.2
Luego en el formulario que va a mostrar el reporte debes instanciar el control CrViewer9, si no tienes en tu cuadro de controles lo puedes agregar en Componentes y activas El Crystak Report Viewer Control 9.
El codigo sería el siguiente
Dim CrApp As New CRAXDDRT.Application
Dim CrReporte As New CRAXDDRT.Report
'Ruta del reporte
Set CrReporte = CrApp.OpenReport("C:\reporte.rpt", 1)
'Titulo del reporte
CrReporte.ReportTitle = "Listado General de Materiales"
'crVistaReporte --> control crViewer9
Me.crVistaReporte.ReportSource = CrReporte
Me.crVistaReporte.ViewReport
Espero poder haberte dado una mano ...
Que tal gracias por la ayuda, en base a tu codigo de ejemplo y estar investigando logre formar este codigo
Código:
Private Sub Form_Load()
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
On Error GoTo ErrHandler
Screen.MousePointer = vbHourglass
mflgContinuar = True
Set crReport = crApp.OpenReport(App.Path & "\Receta.rpt", 1)
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "text2"
crParamDef.AddCurrentValue (mstrParametro1)
End Select
Next
CRViewer.ReportSource = crReport
CRViewer.DisplayGroupTree = False
CRViewer.ViewReport
Screen.MousePointer = vbDefault
Set crParamDefs = Nothing
Set crParamDef = Nothing
Exit Sub
ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "El archivo de reporte no se encuentra", vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If
mflgContinuar = False
Screen.MousePointer = vbDefault
End Sub
y me muestra mi reporte, pero el problema q tengo es que me muestra toda la informacion de mi tabla, pero lo q yo necesito es q me muestre la informacion q se encuentra en un formulario que contiene textbox, no se si ahi este haciendo mal mi reporte o estoy haciendo mal el llamado de mi parametros..........
Saludos y gracias por las respuestas