Ayuda de Crystal Report

Quisiera que me ayudaras, (si esta dentro de tus posibilidades), a que me explicaras como debe hacerse para crear un reporte en Crystal Report 8 que se genere entre dos rangos de fecha estoy utilizando Visual Basic 6.0, y Access 2000. Te lo agradeceré

1 respuesta

Respuesta
1
Tienes que agregar una fórmula en tu reporte de crystal reports y algo de código como el siguiente:
Screen.MousePointer = 11
If right(App.Path, 1) = "\" Then
RUTA$ = App.Path
Else
RUTA$ = App.Path & "\"
End If
frmRegistroInformacion.Acuse.Formulas(0) = ""
If NombreReporte = "acuse.rpt" Or NombreReporte = "conclusion.rpt" Then
If NoFolio = 0 Or Anio = 0 Then
Exit Sub
End If
sFormula = "{vie_consultas.no_folio} = " & NoFolio & " and {vie_consultas.anio} = " & Anio
Select Case gUNivel$
Case 1, 2: 'Oficialia de partes y presidencia
Case 3: 'Vicepresidencia
sFormula = sFormula & " and ({vie_consultas.area_tiene} like '" & Left(gUArea$, 1) & "*'"
Case 4: 'Dirección general
sFormula = sFormula & " and ({vie_consultas.area_tiene} like '" & Left(gUArea$, 2) & "*'"
Case 5: 'Dirección de area
sFormula = sFormula & " and ({vie_consultas.area_tiene} like '" & Left(gUArea$, 3) & "*'"
Case 6: 'Subdirección
sFormula = sFormula & " and ({vie_consultas.area_tiene} like '" & Left(gUArea$, 4) & "*'"
Case 7: 'Inspectores
sFormula = sFormula & " and ({vie_consultas.area_tiene} like '" & Left(gUArea$, 5) & "*'"
Case Else:
MsgBox "Error al imprimir reporte. Consulte a su Administrador", vbExclamation, "Reporte Acuse"
Exit Sub
End Select
If gUNivel$ <> 1 And gUNivel$ <> 2 Then
sFormula = sFormula & " or {vie_consultas.area_recibio} = '" & gUArea & "')"
End If
'If NombreReporte = "acuse.rpt" Then
' sFormula = sFormula & " AND {vie_consultas.area_recibio} = '" & gUArea & "'"
'End If
ElseIf NombreReporte = "asuntoseg.rpt" Then
If NoFolio = 0 Or Anio = 0 Then
Exit Sub
End If
' seguimiento del asunto
sFormula = "{ori_cgi_wf.no_folio} = " & NoFolio & " and {ori_cgi_wf.anio} = " & Anio
ElseIf NombreReporte = "pendientes.rpt" Then
frmRegistroInformacion.Acuse.Formulas(0) = "Responsable = '" & frmReporteAsuntosPendientes.txtDescripcion.Text & "'"
If frmReporteAsuntosPendientes.OptAsuntosVAU Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'SI'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosPresidencia Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'PR'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosVicePresidencia Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'VP'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosDG Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'DG'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosGerencia Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'GR'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosMesaControl Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'MC'"
ElseIf frmReporteAsuntosPendientes.OptAsuntosOficina Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'NO'"
Else
sTipoAsuntos = ""
End If
If Len(sCOndiciones) = 5 Then
If frmReporteAsuntosPendientes.OptSoloArea Then
sFormula = "{vie_consultas.area_tiene} = '" & Trim(sCOndiciones) & "'"
Else
sQuery = "SELECT nivel_area_funcional " & _
"FROM cat_cgi_nivel_area_funcional " & _
"WHERE area_funcional = '" & sCOndiciones & "'"
'¿Existe información en el Query?
Set gcx_Conexion = New ADODB.Connection
Set grs_Recordset = Nothing
gcx_Conexion.CommandTimeout = 5200
If Conexion.gf_AbreRecordset1(gcx_Conexion, grs_Recordset, mDSN$, mUsuario$, mPassword$, sQuery, mBaseDatos$, adOpenForwardOnly, adLockReadOnly) Then
If Not grs_Recordset.EOF Then
' seleccionar el nivel de mi área y
Select Case grs_Recordset.Fields(0)
Case 1, 2: 'Oficialia de partes y presidencia
PGeneral.FGFNErrorBox ("Error con los datos seleccionados. Favor de verificar")
MsgBox "No se tiene acceso al Catálogo de Tipo de Asuntos.", vbExclamation, "Sistema de Control de Gestión Institucional"
Exit Sub
Case 3: 'Vicepresidencia
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 1) & "*'"
Case 4: 'Dirección general
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 2) & "*' AND {vie_consultas.area_tiene} <> '" & Left(sCOndiciones, 1) & "0000'"
Case 5: 'Dirección de area
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 3) & "*' AND {vie_consultas.area_tiene} <> '" & Left(sCOndiciones, 2) & "000'"
Case 6: 'Subdirección
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 4) & "*' AND {vie_consultas.area_tiene} <> '" & Left(sCOndiciones, 3) & "00'"
Case 7: 'Inspecciones
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 5) & "*' AND {vie_consultas.area_tiene} <> '" & Left(sCOndiciones, 4) & "0'"
End Select
End If
End If
' ahora se desconecta para no tener problemas con las licencias
Call Conexion.gs_CierraBaseDatos(gcx_Conexion)
End If
Else
sFormula = "{vie_consultas.usuario} = '" & Trim(sCOndiciones) & "'"
End If
sFormula = sFormula & " and {vie_consultas.status_actual} in [1,2,3,5,7,9]"
sFormula = sFormula & sTipoAsuntos
'Reporte mensual de asuntos pendientes
'solo para Presidencia y VAU
ElseIf NombreReporte = "rementra.rpt" Then
frmRegistroInformacion.Acuse.Formulas(0) = "Responsable = '" & frmReporteAsuntosPendientes.txtDescripcion.Text & "'"
MesInicial = CualMes(Format$(frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value, "M"))
MesFinal = CualMes(Format$(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "M"))
Anio = Format$(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "yyyy")
If MesInicial = MesFinal Then
frmRegistroInformacion.Acuse.Formulas(1) = "Periodo = '(" & MesInicial & " " & Anio & ")'"
Else
frmRegistroInformacion.Acuse.Formulas(1) = "Periodo = '(" & MesInicial & " - " & MesFinal & " " & Anio & ")'"
End If
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 1) & "*'"
FechaInicial = frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value
FechaFinal = frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value
FechaFinal = DateAdd("d", 1, frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value)
FechaInicial = Format(frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value, "yyyy, mm, dd")
FechaFinal = Format(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "yyyy, mm, dd")
sFormula = sFormula & " and {vie_consultas.status_actual} in [1,2,3,5,7,9]"
sFormula = sFormula & " and {vie_consultas.fecha_registro} >= Date (" & FechaInicial & ")"
sFormula = sFormula & " and {vie_consultas.fecha_registro} <= Date (" & FechaFinal & ")"
If gUArea$ = "10001" Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'SI'"
ElseIf gUArea$ = "10000" Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'PR'"
End If
sFormula = sFormula & sTipoAsuntos
'Reporte mensual de asuntos concluidos
'solo para Presidencia y VAU
ElseIf NombreReporte = "remecon.rpt" Then
frmRegistroInformacion.Acuse.Formulas(0) = "Responsable = '" & frmReporteAsuntosPendientes.txtDescripcion.Text & "'"
MesInicial = CualMes(Format(frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value, "M"))
MesFinal = CualMes(Format(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "M"))
Anio = Format(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "yyyy")
If MesInicial = MesFinal Then
frmRegistroInformacion.Acuse.Formulas(1) = "Periodo = '(" & MesInicial & " " & Anio & ")'"
Else
frmRegistroInformacion.Acuse.Formulas(1) = "Periodo = '(" & MesInicial & " - " & MesFinal & " " & Anio & ")'"
End If
sFormula = "{vie_consultas.area_tiene} like '" & Left(sCOndiciones, 1) & "*'"
FechaInicial = frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value
FechaFinal = frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value
FechaFinal = DateAdd("d", 1, frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value)
FechaInicial = Format(frmReporteAsuntosPendientes.medF_RegistroSCGI1.Value, "yyyy, mm, dd")
FechaFinal = Format(frmReporteAsuntosPendientes.medF_RegistroSCGI2.Value, "yyyy, mm, dd")
sFormula = sFormula & " and {vie_consultas.status_actual} in [4,6]"
sFormula = sFormula & " and {vie_consultas.f_conclusion} >= Date (" & FechaInicial & ")"
sFormula = sFormula & " and {vie_consultas.f_conclusion} <= Date (" & FechaFinal & ")"
If gUArea$ = "10001" Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'SI'"
ElseIf gUArea$ = "10000" Then
sTipoAsuntos = " and {vie_consultas.etiqueta_vau} = 'PR'"
End If
sFormula = sFormula & sTipoAsuntos
'Reporte de asuntos registrados durante el día
'solo para Presidencia y VAU
ElseIf NombreReporte = "asuntosreg.rpt" Then
sFormula = "{his_cgi_wf.area_recibio} = '" & gUArea$ & "'" & _
" and {his_cgi_wf.f_asignacion_area} >= date(" & Format(Now(), "yyyy,mm,dd") & ")"
ElseIf NombreReporte = "acuseglobal.rpt" Then
If gsAreaSeleccionada = "" Then
Exit Sub
End If
sFormula = "{vie_consultas.area_recibio} = '" & gUArea$ & "'" & _
" and {vie_consultas.area_tiene} = '" & gsAreaSeleccionada & "'" & _
" and {vie_consultas.f_asignacion_area} >= date(" & Format(Now(), "yyyy,mm,dd") & ")"
If gsTipoAsuntos <> "" Then
sFormula = sFormula & " and {vie_consultas.etiqueta_vau} = '" & gsTipoAsuntos & "'"
End If
Else
MsgBox "Error. El Reporte no existe. Favor de llamar al administrador", vbCritical, "Reportes Predefinidos"
Exit Sub
End If
frmRegistroInformacion.Acuse.ReportFileName = RUTA$ & NombreReporte
frmRegistroInformacion.Acuse.WindowTitle = "Reportes Predefinidos"
frmRegistroInformacion.Acuse.SelectionFormula = sFormula
frmRegistroInformacion.Acuse.Connect = MsAux$
frmRegistroInformacion.Acuse.DiscardSavedData = True
frmRegistroInformacion.Acuse.Destination = crptToWindow
frmRegistroInformacion.Acuse.Action = 0
Y también checa las siguientes ligas para encontrar tutoriales y manuales de crystal reports.
http://www.google.com.mx/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&hl=es&q=tutorial+de+crystal+report&meta=&btnG=B%C3%BAsqueda+en+Google
http://www.google.com.mx/search?hl=es&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&q=manual+de+crystal+report&btnG=B%C3%BAsqueda&meta=

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas