CRISTAL REPORT
ALguien sabe como se puede hacer un listado en Cristal Report a partir de un REcordset o bien a partir del resultado de un procedimiento almacenado de SQlServer al que se le puedan pasar parametros???? .
Muchas Gracias.
Muchas Gracias.
NESECITAS GENERAR TU CONSULTA CON LOS PARAMETROS QUE TU QUIERES INTRODUCIR Y QUE SE VISUALICEN EN TU REPORTE.........
EL SIGUIENTE CODIGO TE MOSTRARA UN EJEMPLO OK..
----------------------------------------------------
TE MOSTRAREMOS UN EJEMPLO DE UNA CONSULTA
---------
strSql = ""
strSql = strSql & " SELECT qry_auditorias.id_ejercicio, "
strSql = strSql & " qry_auditorias.id_tipo, qry_auditorias.tipo AS tipo, "
strSql = strSql & " qry_auditorias.id_dep, qry_auditorias.dep, "
strSql = strSql & " qry_auditorias.id_sdep, qry_auditorias.sdep, "
strSql = strSql & " qry_auditorias.id_auditoria, qry_auditorias.concepto, "
strSql = strSql & " qry_auditorias.id_periodo, "
strSql = strSql & " qry_auditorias.dep, qry_auditorias.id_ejercicio AS ejercicio, "
strSql = strSql & " qry_obs_aud.consec, qry_obs_aud.id_ejer, qry_obs_aud.id, "
strSql = strSql & " qry_obs_aud.id_clasif, qry_obs_aud.clasif, "
strSql = strSql & " qry_obs_aud.observacion, qry_obs_aud.recomienda, "
strSql = strSql & " qry_obs_aud.accion, qry_obs_aud.requiere, "
strSql = strSql & " qry_obs_aud.id_status, qry_obs_aud.status, "
strSql = strSql & " qry_obs_aud.fec_alta, qry_obs_aud.id_ejercicio AS ejer, "
strSql = strSql & " qry_obs_aud.id_fis, qry_obs_aud.fiscal, "
strSql = strSql & " qry_obs_aud.no_revision, qry_obs_aud.criterio, "
strSql = strSql & " qry_auditorias.id_fed, qry_auditorias.nom_fed, qry_obs_aud.id_status_def "
strSql = strSql & " FROM qry_auditorias LEFT JOIN qry_obs_aud ON "
strSql = strSql & " (qry_auditorias.id_ejercicio = qry_obs_aud.id_ejercicio) "
strSql = strSql & " AND (qry_auditorias.id_dep = qry_obs_aud.id_dep) AND "
strSql = strSql & " (qry_auditorias.id_tipo = qry_obs_aud.id_tipo) AND "
strSql = strSql & " (qry_auditorias.id_auditoria = qry_obs_aud.id_auditoria) AND "
strSql = strSql & " (qry_auditorias.id_periodo = qry_obs_aud.id_periodo) and (qry_auditorias.id_fed = qry_obs_aud.id_fed) "
strSql = strSql & " WHERE ((qry_auditorias.id_ejercicio)='" & cve_ejercicio & "') "
strSql = strSql & " AND ((qry_auditorias.id_tipo)='" & cve_tipo_aud & "') "
strSql = strSql & " AND ((qry_auditorias.id_dep)=" & cve_dep & ") "
strSql = strSql & " AND ((qry_auditorias.id_fed)=" & 0 & ")"
strSql = strSql & " AND ((qry_obs_aud.id_fis)=" & cve_fis & ")"
strSql = strSql & " AND ((qry_obs_aud.id_status_def)='" & 2 & "'"
strSql = strSql & " OR ((qry_obs_aud.id_status_def)='" & 7 & "'))"
Set rs_ejer = New ADODB.Recordset
rs_ejer.LockType = adLockPessimistic
rs_ejer.CursorLocation = adUseClient
rs_ejer.Open Source:=strSql, ActiveConnection:=BD
----------
Y UN EJEMPLO DE COMO SE HACE EN CRISTAL REPORT
DESDE EL CODIGO DE VISUAL OK
If rs_ejer.RecordCount >= 1 Then
res = MsgBox("El Registro Existe" & " ¿Deseas Visualizar el Reporte? ", vbYesNo, "Contraloria")
If res = vbYes Then
'cve_id_aud = rs_ejer!id_auditoria
'MsgBox "{qry_aud_obs.id_ejercicio}= '" & cve_ejercicio & "'" & " AND {qry_aud_obs.id_tipo}= '" & cve_tipo_aud & "'" '& " AND {qry_aud_obs.id_dep}=" & cve_dep & " AND {qry_aud_obs.id_fis}= " & cve_fis
'If frm_gral2.Combo4.Text = "Solventadas" Then
dep = rs_ejer!dep
nomsdep = ""
cve_sit = "2"
CrystalReport2.RetrieveDataFiles
CrystalReport2.SelectionFormula = "{qry_aud_obs1.id_ejercicio}= '" & cve_ejercicio & "'" & " AND {qry_aud_obs1.id_tipo}= '" & cve_tipo_aud & "' " & " AND {qry_aud_obs1.id_dep}=" & cve_dep & " AND {qry_aud_obs1.id_fis}=" & cve_fis & " AND {qry_aud_obs1.id_fed}=" & 0 & " AND (({qry_aud_obs1.id_status_def})='2'" & " OR ({qry_aud_obs1.id_status_def})='7')"
CrystalReport2.Connect = "dsn=; uid=; pwd=SERVER; dsq="
CrystalReport2.ParameterFields(0) = "dep; " + dep + ";TRUE"
CrystalReport2.ParameterFields(1) = "sdep; " + nomsdep + ";TRUE"
CrystalReport2.Action = 1
End If
Else
MsgBox "No se Encontro Informacion con los Datos Proporcionados", vbCritical, "Contraloria"
End If
--------------------------------------------
ESPERAMOS QUE TE SIRVA SI NO MANDANOS UN E-MAIL Y TE MANDAMOS EL ARCHIVO DE CRISTAL.........
OK
ADIOS
EL SIGUIENTE CODIGO TE MOSTRARA UN EJEMPLO OK..
----------------------------------------------------
TE MOSTRAREMOS UN EJEMPLO DE UNA CONSULTA
---------
strSql = ""
strSql = strSql & " SELECT qry_auditorias.id_ejercicio, "
strSql = strSql & " qry_auditorias.id_tipo, qry_auditorias.tipo AS tipo, "
strSql = strSql & " qry_auditorias.id_dep, qry_auditorias.dep, "
strSql = strSql & " qry_auditorias.id_sdep, qry_auditorias.sdep, "
strSql = strSql & " qry_auditorias.id_auditoria, qry_auditorias.concepto, "
strSql = strSql & " qry_auditorias.id_periodo, "
strSql = strSql & " qry_auditorias.dep, qry_auditorias.id_ejercicio AS ejercicio, "
strSql = strSql & " qry_obs_aud.consec, qry_obs_aud.id_ejer, qry_obs_aud.id, "
strSql = strSql & " qry_obs_aud.id_clasif, qry_obs_aud.clasif, "
strSql = strSql & " qry_obs_aud.observacion, qry_obs_aud.recomienda, "
strSql = strSql & " qry_obs_aud.accion, qry_obs_aud.requiere, "
strSql = strSql & " qry_obs_aud.id_status, qry_obs_aud.status, "
strSql = strSql & " qry_obs_aud.fec_alta, qry_obs_aud.id_ejercicio AS ejer, "
strSql = strSql & " qry_obs_aud.id_fis, qry_obs_aud.fiscal, "
strSql = strSql & " qry_obs_aud.no_revision, qry_obs_aud.criterio, "
strSql = strSql & " qry_auditorias.id_fed, qry_auditorias.nom_fed, qry_obs_aud.id_status_def "
strSql = strSql & " FROM qry_auditorias LEFT JOIN qry_obs_aud ON "
strSql = strSql & " (qry_auditorias.id_ejercicio = qry_obs_aud.id_ejercicio) "
strSql = strSql & " AND (qry_auditorias.id_dep = qry_obs_aud.id_dep) AND "
strSql = strSql & " (qry_auditorias.id_tipo = qry_obs_aud.id_tipo) AND "
strSql = strSql & " (qry_auditorias.id_auditoria = qry_obs_aud.id_auditoria) AND "
strSql = strSql & " (qry_auditorias.id_periodo = qry_obs_aud.id_periodo) and (qry_auditorias.id_fed = qry_obs_aud.id_fed) "
strSql = strSql & " WHERE ((qry_auditorias.id_ejercicio)='" & cve_ejercicio & "') "
strSql = strSql & " AND ((qry_auditorias.id_tipo)='" & cve_tipo_aud & "') "
strSql = strSql & " AND ((qry_auditorias.id_dep)=" & cve_dep & ") "
strSql = strSql & " AND ((qry_auditorias.id_fed)=" & 0 & ")"
strSql = strSql & " AND ((qry_obs_aud.id_fis)=" & cve_fis & ")"
strSql = strSql & " AND ((qry_obs_aud.id_status_def)='" & 2 & "'"
strSql = strSql & " OR ((qry_obs_aud.id_status_def)='" & 7 & "'))"
Set rs_ejer = New ADODB.Recordset
rs_ejer.LockType = adLockPessimistic
rs_ejer.CursorLocation = adUseClient
rs_ejer.Open Source:=strSql, ActiveConnection:=BD
----------
Y UN EJEMPLO DE COMO SE HACE EN CRISTAL REPORT
DESDE EL CODIGO DE VISUAL OK
If rs_ejer.RecordCount >= 1 Then
res = MsgBox("El Registro Existe" & " ¿Deseas Visualizar el Reporte? ", vbYesNo, "Contraloria")
If res = vbYes Then
'cve_id_aud = rs_ejer!id_auditoria
'MsgBox "{qry_aud_obs.id_ejercicio}= '" & cve_ejercicio & "'" & " AND {qry_aud_obs.id_tipo}= '" & cve_tipo_aud & "'" '& " AND {qry_aud_obs.id_dep}=" & cve_dep & " AND {qry_aud_obs.id_fis}= " & cve_fis
'If frm_gral2.Combo4.Text = "Solventadas" Then
dep = rs_ejer!dep
nomsdep = ""
cve_sit = "2"
CrystalReport2.RetrieveDataFiles
CrystalReport2.SelectionFormula = "{qry_aud_obs1.id_ejercicio}= '" & cve_ejercicio & "'" & " AND {qry_aud_obs1.id_tipo}= '" & cve_tipo_aud & "' " & " AND {qry_aud_obs1.id_dep}=" & cve_dep & " AND {qry_aud_obs1.id_fis}=" & cve_fis & " AND {qry_aud_obs1.id_fed}=" & 0 & " AND (({qry_aud_obs1.id_status_def})='2'" & " OR ({qry_aud_obs1.id_status_def})='7')"
CrystalReport2.Connect = "dsn=; uid=; pwd=SERVER; dsq="
CrystalReport2.ParameterFields(0) = "dep; " + dep + ";TRUE"
CrystalReport2.ParameterFields(1) = "sdep; " + nomsdep + ";TRUE"
CrystalReport2.Action = 1
End If
Else
MsgBox "No se Encontro Informacion con los Datos Proporcionados", vbCritical, "Contraloria"
End If
--------------------------------------------
ESPERAMOS QUE TE SIRVA SI NO MANDANOS UN E-MAIL Y TE MANDAMOS EL ARCHIVO DE CRISTAL.........
OK
ADIOS
Mirè esta ayuda en el foro y me sirve de ayuda para mis estudios, talvez si me pueden ayudar con el archivo de el ejemplo anterior. Les agradesco
Alvaro
Quito Ecuador
Alvaro
Quito Ecuador
