Hola, tengo el siguiente código, y no sé porqué si es el mismo, al crear un nuevo registro funciona pefectamente pero si lo edito no, me dice:
El valor de BOF o EOF es True, o el registro actual se eliminó; la operación solicitada requiere un registro actual
El código es el siguiente:
Código:
Private Sub btnAceptar_Click()
If TipoOpcion = 0 Then 'Nuevo Registro
On Error GoTo errorcreacion
Cargar ("select * from productos where cod_art ='" & Trim(txtCod.Text) & "'")
If rsRegistro.EOF = True Then
rsRegistro.AddNew
'txtCod.Enabled = True
rsRegistro!cod_art = txtCod.Text
rsRegistro!Nombre = txtNom.Text & ""
rsRegistro!descripcion = txtDescri.Text & ""
rsRegistro!pco = txtpco.Text & ""
rsRegistro!pvp = txtpvp.Text & ""
rsRegistro!stock = txtStock.Text & ""
If chkDescatalogado.Value = 1 Then
rsRegistro!descatalogado = "SI"
Else
rsRegistro!descatalogado = "NO"
End If
rsRegistro!f_alta = dtpF_Alta.Value
rsRegistro!hoja = txtHoja.Text & ""
rsRegistro!tmpPlan = txtPlan.Text & ""
rsRegistro!tmpFlor = txtFlor.Text & ""
'rsRegistro!imgFoto =
rsRegistro!cod_rie = txtRie.Text & ""
rsRegistro!cod_man = txtMan.Text & ""
rsRegistro!cod_prov = txtProv.Text & ""
rsRegistro.Update
Else
Exit Sub
End If
Else
If TipoOpcion = 1 Then 'Modificación de Registro
On Error GoTo errormodificacion
Cargar ("select * from Productos where cod_art ='" & Trim(txtCod.Text) & "'")
rsRegistro.Find ("select * from Productos where cod_art ='" & Trim(txtCod.Text) & "'")
rsRegistro!cod_art = txtCod.Text
rsRegistro!Nombre = txtNom.Text & ""
rsRegistro!descripcion = txtDescri.Text & ""
rsRegistro!pco = txtpco.Text & ""
rsRegistro!pvp = txtpvp.Text & ""
rsRegistro!stock = txtStock.Text & ""
If chkDescatalogado.Value = 1 Then
rsRegistro!descatalogado = "SI"
Else
rsRegistro!descatalogado = "NO"
End If
rsRegistro!f_alta = dtpF_Alta.Value
rsRegistro!hoja = txtHoja.Text & ""
rsRegistro!tmpPlan = txtPlan.Text & ""
rsRegistro!tmpFlor = txtFlor.Text & ""
'rsRegistro!imgFoto =
rsRegistro!cod_rie = txtRie.Text & ""
rsRegistro!cod_man = txtMan.Text & ""
rsRegistro!cod_prov = txtProv.Text & ""
rsRegistro.Update
Else 'Eliminación de Registro
If MsgBox("¿Esta seguro de borrar el producto?", vbApplicationModal + vbYesNo + vbDefaultButton2 + vbExclamation, "Borrar registro") = vbYes Then
On Error GoTo erroreliminacion
Cargar ("select * from Productos where cod_art ='" & Trim(txtCod.Text) & "'")
rsRegistro.Delete
rsRegistro.Update
End If
End If
frmProductosLista.adoAux.Refresh
frmProductosLista.dtgAux.Refresh
End If
rsRegistro.Close
rsRegistro.Open
Unload Me
Exit Sub
errorcreacion:
'If Err.Number = -2147467259 Then
'MsgBox "El NIF/CIF introducido ya existe!", vbExclamation, "El NIF/CIF ya existe"
'txtNIF.SetFocus
'Exit Sub
'Else
MsgBox Err.Number, vbCritical, "Error"
Exit Sub
'End If
errormodificacion:
MsgBox Err.Description, vbCritical, "Error"
Exit Sub
erroreliminacion:
MsgBox Err.Description, vbCritical, "Error"
Exit Sub
End Sub
SI me podeis ayudar os lo agradezco muchísimo. Un Saludo!
PD:este código lo tengo en otros formularios tal cual y no me da ningún error.