RE:Cambiar Origen de Datos en el Reporte
Publicado por
Oriol (1 intervención) el 14/11/2007 10:09:00
Personalmente utilizo el código siguiente:
El problema con el que me encuentro es que si genero un subReport y lo vinculo desde el CRDesigner, al cambiar el origen de la base de datos, cuando abro el raport principal la ejecución del código para el subRaport no se activa y busca el origen predefinido.
Busco una solución para que el subRaport encuentre la nueva dirección de base de datos.
Dim Report As New CR_Nota
Dim oRsNota As ADODB.Recordset
Private Sub activaRep()
On Error GoTo atrapaError
Dim sTrNota As String
Screen.MousePointer = vbHourglass
posMDI Me
sTrNota = "SELECT tbl_Nota.IdNota, [Apellido] & ', ' & [nom] AS NomE, tbl_Nota.dataNota, tbl_Nota.Proposito, " & _
"tbl_Nota.Anticipo, tbl_Nota.preparacio, tbl_Nota.acceptacio, tbl_Nota.pago " & _
"FROM tbl_Empleat RIGHT JOIN tbl_Nota ON tbl_Empleat.idEmpleat = tbl_Nota.IdEmpleado " & _
"WHERE (((tbl_Nota.IdNota)=" & numNotaPerRep & "))"
Set oRsNota = New ADODB.Recordset
Report.Database.SetDataSource New_RetornaRecordsetEd(sTrNota)
If CRViewer1.Visible Then
Report.ReadRecords
CRViewer1.Refresh
End If
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
' frmCRNotaDetall.CRViewerDetall.ActivateView (1)
' CRViewerDetall.activaRepDetall
Screen.MousePointer = vbDefault
Set oRsNota = Nothing
atrapaError:
If Err.Number = -2147483638 Then
Resume Next
Else
Debug.Print Err.Number & ", " & Err.Description
End If
End Sub
Private Sub Form_Load()
activaRep
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
' CRViewer1.Refresh
activaRep
End Sub