
11/05/2009, 06:49
|
| | Fecha de Ingreso: abril-2005
Mensajes: 483
Antigüedad: 20 años, 1 mes Puntos: 3 | |
Respuesta: Crystal Reporte no muestra el último registro Hola, gracias por responder.
El registro último registro si existe en la tabla y el Crystal no lo muestra.
Este es el código que recorre la tabla cuentacorriente y graba en la tabla auxiliar saldos.
Código:
Dim rs As New ADODB.Recordset, idcuenta As Long
Dim saldoinicial As Double, debitos As Double, Creditos As Double
Dim cadena As String, cuentas As Variant, I As Integer
cadena = Empty
If Len(TxCuentas) > 0 Then
cuentas = Split(TxCuentas, ",")
For I = 0 To UBound(cuentas)
If I = 0 Then
cadena = cadena & " idcuenta = " & cuentas(I)
Else
cadena = cadena & " OR idcuenta = " & cuentas(I)
End If
Next
Else
cadena = "True"
End If
rs.Open "SELECT * FROM cuentacorriente WHERE " & cadena & " AND fecha <= #" & Format(DTHasta, "mm/dd/yyyy") & "# ORDER BY idcuenta, fecha, tipodoc, contrapartida", conn, adOpenDynamic, adLockOptimistic
If rs.EOF Then
MsgBox "No existen movimientos con los datos solicitados", vbExclamation, "Atención"
Else
conninf.Execute ("DELETE * FROM saldos")
Do While Not rs.EOF
idcuenta = rs!idcuenta
saldoinicial = 0: debitos = 0: Creditos = 0
Do While idcuenta = rs!idcuenta
If rs!tipodoc = 0 Then
saldoinicial = rs!Importe
debitos = 0: Creditos = 0
ElseIf rs!tipodoc = 1 Or rs!tipodoc = 3 Then
If rs!fecha < DTDesde Then
saldoinicial = saldoinicial + rs!Importe
Else
debitos = debitos + rs!Importe
End If
ElseIf rs!tipodoc = 2 Or rs!tipodoc = 4 Then
If rs!fecha < DTDesde Then
saldoinicial = saldoinicial - rs!Importe
Else
Creditos = Creditos + rs!Importe
End If
End If
rs.MoveNext
If rs.EOF Then
Exit Do
End If
Loop
conninf.Execute ("INSERT INTO saldos (idcuenta,saldoinicial,debitos,creditos,saldofinal) values('" & idcuenta & "','" & saldoinicial & "','" & debitos & "','" & Creditos & "','" & saldoinicial + debitos - Creditos & "')")
Loop
TitReporte = "Lisado de Saldos"
FoReporte.PasarParametros DTDesde, DTHasta, ""
ArcReporte = "saldos.rpt"
FoReporte.Show
End If
rs.Close
Este es el código del formulario FoReporte:
Código:
Option Explicit
Private crApp As New CRAXDRT.Application
Private crReport As New CRAXDRT.Report
Private Parametro1 As Date
Private Parametro2 As Date
Private Parametro3 As String
Private Sub Form_Load()
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
FoReporte.Caption = TitReporte
Screen.MousePointer = vbHourglass
Set crReport = crApp.OpenReport(App.Path & "\" & ArcReporte, 1)
' Parametros del reporte
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "parametro1"
crParamDef.AddDefaultValue (Parametro1)
Case "parametro2"
crParamDef.AddDefaultValue (Parametro2)
Case "parametro3"
crParamDef.AddDefaultValue (Parametro3)
End Select
Next
CRViewer.ReportSource = crReport
CRViewer.DisplayGroupTree = False
crReport.DiscardSavedData
CRViewer.ViewReport
Screen.MousePointer = vbDefault
Set crParamDefs = Nothing
Set crParamDef = Nothing
End Sub
Private Sub Form_Resize()
CRViewer.Top = 0
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set crReport = Nothing
Set crApp = Nothing
End Sub
Public Sub PasarParametros(sParam1 As Date, lParam2 As Date, lParam3 As String)
Parametro1 = sParam1
Parametro2 = lParam2
Parametro3 = lParam3
End Sub
Gracias y saludos |