Corro la app enTiempo de diseño y se cierra. HELP!
Publicado por Jorge (56 intervenciones) el 10/12/2010 19:09:21
el problema va con este codigo, ya probe modulo por modulo y se resume a lo que sigue.
cuando activo el codigo para mostrar el reporte (al menos paraece eso, podria ser la conexion a la BD, pero cuando no pongo el codigo para crystal reports no se cierra la app)
El asuto va asi, en tiempo de diseño, corro la app, le doy al boton de generar consulta, funciona ok, cierro la app y regreso al codigo fuente, peeeero, vuelvo a correr la app, le doy al boton de generar consulta y pum! se cierra todo, la app y el codigo fuente, todo.
Que esta mal en el codigo????, alguien que me pueda iluminar? :(
Aqui lo principal del codigo:
Gracias:
================================================
'/****************** VARIABLES PARA CRYSTAL ******************\'
Dim crApp As CRAXDRT.Application
Dim crReport As CRAXDRT.Report
Dim crSubReport As CRAXDRT.Report
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
'/****************** VARIABLES PARA REGISTROS ******************\'
Private cnn As ADODB.Connection
Private rstCAB As ADODB.Recordset
Private rstDET As ADODB.Recordset
'/******** BOTON QUE GENERA LA CONSULTA Y MUESTRA REPORTE ********\'
Private Sub RealizarConsulta_Click()
Set crApp = New CRAXDRT.Application
Set crReport = New CRAXDRT.Report
Set crSubReport = New CRAXDRT.Report
Set cnn = New ADODB.Connection
Set rstCAB = New ADODB.Recordset
Set rstDET = New ADODB.Recordset
On Error GoTo ErrHandler
cnn.Open "Provider = Microsoft.Jet.OLEDB.4.0 ;" & "Data Source=" & App.Path & "\Mi_BD.mdb ;"
cnn.CursorLocation = adUseClient
rstCAB.Open Mi_SentenciaSQL("CAB"), cnn, adOpenDynamic, adLockOptimistic
rstDET.Open Mi_SentenciaSQL("DET"), cnn, adOpenDynamic, adLockOptimistic
Set crReport = crApp.OpenReport(App.Path & "\Rpt\Mi_Reporte.rpt", 1)
Set crSubReport = crReport.OpenSubreport("Detalle")
crReport.Database.SetDataSource rstCAB
crSubReport.Database.SetDataSource rstDET
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
'.... Aqui Ingreso mis parametros del reporte
End Select
CRV.ReportSource = crReport
CRV.ViewReport
Set crSubReport = Nothing
Set crReport = Nothing
Set crApp = Nothing
Set rstDET = Nothing
Set rstCAB = Nothing
Set cnn = Nothing
Exit Sub
ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "Reporte Perdido", vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If
Set crSubReport = Nothing
Set crReport = Nothing
Set crApp = Nothing
Set rstDET = Nothing
Set rstCAB = Nothing
Set cnn = Nothing
end sub
cuando activo el codigo para mostrar el reporte (al menos paraece eso, podria ser la conexion a la BD, pero cuando no pongo el codigo para crystal reports no se cierra la app)
El asuto va asi, en tiempo de diseño, corro la app, le doy al boton de generar consulta, funciona ok, cierro la app y regreso al codigo fuente, peeeero, vuelvo a correr la app, le doy al boton de generar consulta y pum! se cierra todo, la app y el codigo fuente, todo.
Que esta mal en el codigo????, alguien que me pueda iluminar? :(
Aqui lo principal del codigo:
Gracias:
================================================
'/****************** VARIABLES PARA CRYSTAL ******************\'
Dim crApp As CRAXDRT.Application
Dim crReport As CRAXDRT.Report
Dim crSubReport As CRAXDRT.Report
Dim crParamDef As CRAXDRT.ParameterFieldDefinition
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
'/****************** VARIABLES PARA REGISTROS ******************\'
Private cnn As ADODB.Connection
Private rstCAB As ADODB.Recordset
Private rstDET As ADODB.Recordset
'/******** BOTON QUE GENERA LA CONSULTA Y MUESTRA REPORTE ********\'
Private Sub RealizarConsulta_Click()
Set crApp = New CRAXDRT.Application
Set crReport = New CRAXDRT.Report
Set crSubReport = New CRAXDRT.Report
Set cnn = New ADODB.Connection
Set rstCAB = New ADODB.Recordset
Set rstDET = New ADODB.Recordset
On Error GoTo ErrHandler
cnn.Open "Provider = Microsoft.Jet.OLEDB.4.0 ;" & "Data Source=" & App.Path & "\Mi_BD.mdb ;"
cnn.CursorLocation = adUseClient
rstCAB.Open Mi_SentenciaSQL("CAB"), cnn, adOpenDynamic, adLockOptimistic
rstDET.Open Mi_SentenciaSQL("DET"), cnn, adOpenDynamic, adLockOptimistic
Set crReport = crApp.OpenReport(App.Path & "\Rpt\Mi_Reporte.rpt", 1)
Set crSubReport = crReport.OpenSubreport("Detalle")
crReport.Database.SetDataSource rstCAB
crSubReport.Database.SetDataSource rstDET
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
'.... Aqui Ingreso mis parametros del reporte
End Select
CRV.ReportSource = crReport
CRV.ViewReport
Set crSubReport = Nothing
Set crReport = Nothing
Set crApp = Nothing
Set rstDET = Nothing
Set rstCAB = Nothing
Set cnn = Nothing
Exit Sub
ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "Reporte Perdido", vbCritical + vbOKOnly
Else
MsgBox Err.Description, vbCritical + vbOKOnly
End If
Set crSubReport = Nothing
Set crReport = Nothing
Set crApp = Nothing
Set rstDET = Nothing
Set rstCAB = Nothing
Set cnn = Nothing
end sub
Valora esta pregunta


0