Dim rutaDB As String = "C:\prueba\Crystal\bdfabrica.mdb" Dim informe As String = "C:\prueba\LisVolOperCliDetalle.rpt" Dim informePDF As String = "C:\prueba\LisVolOperCliDetalle.pdf"
Public Sub imprimirInforme()
fechaInicio = CDate("10/10/2016")
fechaFin = CDate("10/10/2017")
diaInicio = (fechaInicio).Day
diaFinal = (fechaFin).Day
mesInicio = (fechaInicio).Month
mesFinal = (fechaFin).Month
annoInicio = (fechaInicio).Year
annoFinal = (fechaFin).Year
Try
With informeRpt
.Database.Tables(0).Location = rutaDB
.RecordSelectionFormula = "{RegIVARe.Fecha_Factura} in Date(" & annoInicio & "," & mesInicio & "," & diaInicio & ") to Date(" & annoFinal & "," & mesFinal & "," & diaFinal & ") AND " & "{RegIVARe.Cod_Cliente} = " & codCliente & ""
End With
parFecInicio.Name = "fechaInicio"
fInicio.Value = fechaInicio
parFecInicio.CurrentValues.Add(fInicio)
parametros.Add(parFecInicio)
parFecFinal.Name = "fechaFinal"
fFinal.Value = fechaInicio
parFecFinal.CurrentValues.Add(fFinal)
parametros.Add(parFecFinal)
cr.ReportSource = informeRpt
cr.DisplayGroupTree = False
cr.Dock = DockStyle.Fill
cr.ParameterFieldInfo = parametros
Dim frmReporte As New Form
With frmReporte
.Controls.Add(cr)
.WindowState = FormWindowState.Maximized
End With
frmReporte.Show()
Thread.Sleep(2000)
informeRpt.ExportToDisk(ExportFormatType.PortableDocFormat, informePDF)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
The code generates the report well, but at the time of creating the pdf
it gives me an error:
en esta linea informeRpt.ExportToDisk(ExportFormatType.PortableDocFormat, informePDF)
This is the error in tiempo de ejecución
:
It's like you're looking for the .rpt
in the temporary folder.
But at the time of export, if you are taking the route where my .pdf
is
Does anyone know where the problem may be?
Thanks