error "3021" en tiempo de ejecucion

crucifijo
06 de Enero del 2006
Hola amigos fijense que estoy haciendo una puequeña aplicacion de horarios para unos profesores, tengo creado un modulo de profesores donde son altas, bajas, cambios, eliminar, ya me he conecte a la base de datos y he puesto el codigo mi problema es que cuando le doy eliminar registro me manda el siguiente error "Error 3021 en tiempo de ejecucion:
El valor de BOF o EOF ES True, o el actual registro se elimino; la operacion solicitada requiere un registro actual." y no se que hacer para corregir el error.

Nota mi base de datos esta hecha en access 2000, les dejo el codigo esperando que me puedan ayudar gracias.


Dim cn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset

Private Sub Anterior_Click()
rs1.MovePrevious
Posterior.Enabled = True
desabilitar
If rs1.BOF = True Then
rs1.MoveFirst
Primero.Enabled = False
Anterior.Enabled = False
Else
refrescar
End If

End Sub


Private Sub Cancelar_Click()
rs1.CancelUpdate
refrescar
desabilitar
End Sub

Private Sub Eliminar_Click()
n = MsgBox("Esta Seguro que desea eliminar el registro?", vbYesNo, "Confirme Eliminacion")
If n = vbYes Then
rs1.Delete
End If
rs1.MovePrevious
rs1.MoveNext
refrescar
End Sub

Private Sub Form_Load()
cn1.Provider = "Microsoft.Jet.OLEDB.4.0"
cn1.ConnectionString = "C:Horarios2Horarios.mdb"
cn1.Open
rs1.Open "select * from profesores", cn1, adOpenKeyset, adLockOptimistic
rs1.MoveFirst
refrescar
desabilitar
End Sub

Private Sub Guardar_Click()
rs1.Fields("IdProfesor") = Text1.Text
rs1.Fields("Nombre") = Text2.Text
rs1.Fields("Apellidos") = Text3.Text
rs1.Fields("Direccion") = Text4.Text
rs1.Fields("Telefono") = Text5.Text
rs1.Fields("Cp") = Text6.Text
rs1.Fields("Rfc") = Text7.Text
rs1.Fields("Curp") = Text8.Text
rs1.Fields("GradoAcademico") = Text9.Text
rs1.Fields("Especialidad") = Text10.Text
rs1.Fields("HorarioLabores") = Text11.Text
rs1.Fields("Historial1") = Text12.Text
rs1.Fields("Historial2") = Text13.Text
rs1.Fields("Itfp") = Text14.Text
rs1.Fields("Ssp") = Text15.Text

rs1.Update
desabilitar
End Sub

Private Sub listadelegaciones_Click(Area As Integer)
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from delegaciones order by DescDel", cn1, adOpenKeyset, adLockOptimistic
Set listadelegaciones.DataSource = rs1
Set listadelegaciones.RowSource = rs1
listadelegaciones.ListField = ("DescDel")
End Sub

Private Sub listaestados_Click(Area As Integer)
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from estados order by DescEst", cn1, adOpenKeyset, adLockOptimistic
Set listaestados.DataSource = rs1
Set listaestados.RowSource = rs1
listaestados.ListField = ("DescEst")
End Sub

Private Sub listapagos_Click(Area As Integer)
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from pagos", cn1, adOpenKeyset, adLockOptimistic
Set listapagos.DataSource = rs1
Set listapagos.RowSource = rs1
listapagos.ListField = ("DescPag")
End Sub
Public Sub refrescar()
Text1.Text = rs1!IdProfesor
Text2.Text = rs1!Nombre
Text3.Text = rs1!Apellidos
Text4.Text = rs1!Direccion
Text5.Text = rs1!Telefono
Text6.Text = rs1!Cp
Text7.Text = rs1!Rfc
Text8.Text = rs1!Curp
Text9.Text = rs1!GradoAcademico
Text10.Text = rs1!Especialidad
Text11.Text = rs1!HorarioLabores
Text12.Text = rs1!Historial1
Text13.Text = rs1!Historial2
Text14.Text = rs1!Itfp
Text15.Text = rs1!Ssp
End Sub

Private Sub limpiar()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
listadelegaciones.Text = ""
listapagos.Text = ""
listaestados.Text = ""
End Sub

Public Sub desabilitar()
If Primero.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = False
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = False
Modificar.Enabled = True
Else
If Nuevo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Salir.Enabled = False
Eliminar.Enabled = False
Modificar.Enabled = False
Else
If Guardar.Value = True Or Cancelar.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Salir.Enabled = True
Eliminar.Enabled = True
Modificar.Enabled = True
Else
If Ultimo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Else
If Modificar.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Eliminar.Enabled = False
Else
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Eliminar.Enabled = True
End If
End If
End If
End If
End If
End Sub

Public Function validar() As Boolean
If rs.BOF = True Or rs.EOF = True Then
validar = False
Else
validar = True
End If
End Function

Private Sub Modificar_Click()
desabilitar
End Sub

Private Sub Nuevo_Click()
rs1.AddNew
limpiar
desabilitar
End Sub

Private Sub Posterior_Click()
rs1.MoveNext
desabilitar
If rs1.EOF = True Then
rs1.MoveLast
Ultimo.Enabled = False
Posterior.Enabled = False
Else
refrescar
End If
End Sub

Private Sub Primero_Click()
rs1.MoveFirst
refrescar
desabilitar
End Sub

Private Sub Salir_Click()
End
End Sub

Private Sub Ultimo_Click()
rs1.MoveLast
refrescar
desabilitar
End Sub