Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

error 3021 en tiempo de ejecucion

Estas en el tema de error 3021 en tiempo de ejecucion en el foro de Visual Basic clásico en Foros del Web. cuando corro mi aplicacion me aparece el sig msj: error 3021 en tiempo de ejecucion either BOF or EOF is true, or the currente record ...
  #1 (permalink)  
Antiguo 26/11/2007, 13:10
 
Fecha de Ingreso: noviembre-2007
Mensajes: 39
Antigüedad: 16 años, 5 meses
Puntos: 0
error 3021 en tiempo de ejecucion

cuando corro mi aplicacion me aparece el sig msj:

error 3021 en tiempo de ejecucion
either BOF or EOF is true, or the currente record has been deleted.
requested operation requires a current record.
  #2 (permalink)  
Antiguo 27/11/2007, 09:10
Avatar de Kruzado  
Fecha de Ingreso: marzo-2007
Mensajes: 307
Antigüedad: 17 años, 2 meses
Puntos: 17
Re: error 3021 en tiempo de ejecucion

ese error lo da cuando no existe el registro buscado o no tienes registros en tu tabla, para solucionarlo escribe al inico de tu codigo

On Error Resume Next

con esto capturas los errores generados en el programa

tambien puedes revisar si estan bien hechas las consultas y si efectivamente la consulta que estas haciend tiene datos
  #3 (permalink)  
Antiguo 27/11/2007, 09:29
 
Fecha de Ingreso: noviembre-2007
Mensajes: 39
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: error 3021 en tiempo de ejecucion

he estado modificando el codigo ..... pero no encuentro la solucion !!! te envio el
codigo.... haber si m puedes ayudar......

Private Sub btn_save_Click()
Dim weekRepId As Integer
Dim appProfile As Integer
Dim projId As String
Dim actId As String
Dim comp As Integer
Dim siExiste As Boolean
Dim countreg As Integer

If Text1.Visible Then
fgd_timesheet = Text1
Text1.Visible = False
RecalcTotal (fgd_timesheet.Col)
End If

'checa si ya esta cerrado el registro
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 1 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

If Not rst.EOF Then Exit Sub

' clean up
rst.Close
Set rst = Nothing

countreg = 0
'adquiere el week_report_id
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 0 " & _
" AND current_week_report.approved = 0 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

siExiste = False

Do While Not rst.EOF
siExiste = True
weekRepId = Val(rst!id)
rst.MoveNext
Loop

' clean up
rst.Close
Set rst = Nothing

If siExiste = True Then
'Elimina registros
strSQL = "Delete from current_daily_entry where week_report_id = " & weekRepId & " "
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
Else
'si no existe el registro sacar week_report_id
Set rst = New ADODB.Recordset
rst.Open "select MAX(id) from current_week_report", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
weekRepId = Val(rst.GetString) + 1
rst.Close
'sacar el apprProfile
Set rst = New ADODB.Recordset
rst.Open "select id from appusr_profile where appr_dept_id = '" & TRDept & "' and isDrag=1 ", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
appProfile = Val(rst.GetString) //aqui marca el error....
rst.Close
'Escribe registro en current_week_report
strSQL = "Insert into current_week_report values (" & weekRepId & "," & _
appProfile & "," & txt_week & ",0)"
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
End If



gracias
  #4 (permalink)  
Antiguo 27/11/2007, 14:16
Avatar de Kruzado  
Fecha de Ingreso: marzo-2007
Mensajes: 307
Antigüedad: 17 años, 2 meses
Puntos: 17
Re: error 3021 en tiempo de ejecucion

al inicio de tu codigo :

on error resume next


...
...
...

appProfile = Val(rst.GetString) //aqui marca el error....
if err.number<>0 then
msgbox("Dato no existe")
else
aqui continua con tu codigo
bla
bla
bla
endif
  #5 (permalink)  
Antiguo 28/11/2007, 11:19
 
Fecha de Ingreso: noviembre-2007
Mensajes: 39
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: error 3021 en tiempo de ejecucion

yap.. gracias, con esa instruccio mi applicacion ya no marca el error....

creo q tengo problemas con las tablas de 1 departamento, pero ya las cheque y no me aparece nada fuera de lo normal...... para poner un update porque hice modificaciones en tablas, lo puedo definir en el inicio del codigo?? o a q nivel va??.....
estoy utilizando esta sintaxis:

UPDATE tabla
SET nombre_campo = 'nuevo_valor'
WHERE opciones_a_tener_en_cuenta
  #6 (permalink)  
Antiguo 28/11/2007, 13:24
Avatar de Kruzado  
Fecha de Ingreso: marzo-2007
Mensajes: 307
Antigüedad: 17 años, 2 meses
Puntos: 17
Re: error 3021 en tiempo de ejecucion

una bez ke tengas todos los datos para actualizar la tabla, puedes por ejemplo tener un boton "grabar" o "actualizar" y en event click de ese boton colocar tu codigo del update
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:40.