Visual Basic - Previsualizar VB-Cristal diferentes registros

Life is soft - evento anual de software empresarial
 
Vista:

Previsualizar VB-Cristal diferentes registros

Publicado por Belen (4 intervenciones) el 13/05/2005 12:19:43
Mensaje enviado desde la IP:-80.58.9.42

Necesito previsualizar (no imprimir) varios registros de una base de datos en cristal report, pero actualmente el código de visual que tengo escrito me abre varios visores en lugar de tener un solo visor con los diferentes registros de la base. ¿Es posible?

Este es el código que tengo escrito para imprimir y visualizar.

Private Sub PrintPI(rst As Recordset, bPreview As Boolean, strFFImpresion As String)
Dim result As Integer
Dim ParameterFieldInfo As PEParameterFieldInfo
Dim strReport As String
ParameterFieldInfo.StructSize = PE_SIZEOF_VARINFO_TYPE

'*** Ruta donde se encuentran almacenados los ficheros rpt. ***
strReport = App.Path & "\rpt\pi.rpt"

'*** Abre el motor de impresión. ***
If PEOpenEngine() = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PEOE", jobnum))
Exit Sub
End If

'*** Bucle para imprimir cada parte. ***
Do While Not rst.EOF

'*** Informe a imprimir. ***
jobnum = PEOpenPrintJob(strReport)
If jobnum = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PEOPJ", jobnum))
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If

'While you can specify exact values for the left, top, width and height of the
'Preview form, in most cases you'll want to use the default values, which scale
'appropriately for the system being used and the report

'*** Si se ha elegido la vista preliminar... ***
If bPreview Then
'*** Vista preliminar de informes. ***
result = PESetDialogParentWindow(jobnum, ReportPreview.hwnd)
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PA.PEOTW", jobnum))
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If
'*** Prepara la salida directa de la ventana de impresión. ***
result = PEOutputToWindow(jobnum, "Vista preliminar de Partes" & vbNullChar, _
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
WS_VISIBLE + WS_CAPTION + WS_BORDER + WS_SYSMENU + WS_THICKFRAME, ReportPreview.hwnd)
'*** Muestra los botones de la barra de impresión. ***
PEShowPrintControls jobnum, False
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PEOTW", jobnum))
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If
Else
result = PEOutputToPrinter(jobnum, 1)
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PEOTP", jobnum))
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If
End If

result = PESetNthParam(jobnum, 0, CStr(rst(0)))
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PESNP", jobnum))
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If

'*** Parametro de fecha de impresión. ***
result = PEGetNthParameterField(jobnum, 0, ParameterFieldInfo)
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, "Error al obtener parametro de fecha de Impresión")
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If
ParameterFieldInfo.CurrentValue = strFFImpresion
ParameterFieldInfo.CurrentValueSet = 1
result = PESetNthParameterField(jobnum, 0, ParameterFieldInfo)
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, "Error al pasar parametro de fecha de Impresión")
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If

' True indicates wait until job is finished before proceeding
result = PEStartPrintJob(jobnum, True)
If result = 0 Then
Call infPanel.InformationOutput(vbCritical, ErrorTrap("PI.PESPJ", jobnum))
Call PEClosePrintJob(jobnum)
'*** Cierra el motor de impresión. ***
Call PECloseEngine
Exit Sub
End If

' for the preview window, execution will proceed when the window is destroyed.
' ie - when the user has finished examining the report and pressed close or print
result = 1
Do While result <> 0
' If a pro edition, we can create our own preview controls, and not use the Crystal ones
DoEvents
result = PEGetWindowHandle(jobnum)
Loop

Call PEClosePrintJob(jobnum)
rst.MoveNext ' Siguiente parte
Loop

'*** Cierra el motor de impresión. ***
Call PECloseEngine

End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder