Hi!
I'm trying to update a row with a recorset but I get the error -2147217864(80040e38) error on updating based on queries. The row to be updated couldn't be found.
However the row is there because I can read the values of the row.
rsmod.ActiveConnection = Inicio.conexion
rsmod.CursorLocation = adUseClient
rsmod.LockType = adLockPessimistic
rsmod.CursorType = adOpenDynamic
rsmod.Source = "SELECT * FROM judprue WHERE " & _
"codigo_p = '" & codigo_ant & "' AND " & _
"fecha_jud = '" & Format(fecha_ant, "dd/mm/yyyy") & "' AND " & _
"juzgado = " & juzgado_ant & " AND " & _
"causa_prod = '" & prod_ant & "' AND " & _
"causa_num = " & num_ant & " AND " & _
"causa_agno = " & año_ant
If juznum_ant <> 0 Then
rsmod.Source = rsmod.Source & " AND juz_num = " & _
juznum_ant
End If
On Error GoTo err_modificar
rsmod.Open
rsmod.Fields("codigo_p") = codigo_key
rsmod.Fields("fecha_jud") = Format(fecha_key, "dd/mm/yyyy")
rsmod.Fields("juzgado") = juzgado_key
If Not IsNull(rsmod.Fields("juz_num")) And (juznum_key <> 0) Then
rsmod.Fields("juz_num") = juznum_key
End If
rsmod.Fields("causa_prod") = Me.prod_key
rsmod.Fields("causa_num") = Me.num_key
rsmod.Fields("causa_agno") = Me.año_key
If mskhora.ClipText <> "" Then
rsmod.Fields("hora") = hora
Else
rsmod.Fields("hora") = Null
End If
If optjuisi.Value Then
rsmod.Fields("juicio") = "S"
Else
rsmod.Fields("juicio") = "N"
End If
If optdijuisi.Value Then
rsmod.Fields("dietas_jud") = "S"
Else
rsmod.Fields("dietas_jud") = "N"
End If
If optdidesi.Value Then
rsmod.Fields("dietas_desp") = "S"
If km <> 0 Then
rsmod.Fields("km") = km
End If
Else
rsmod.Fields("dietas_desp") = "N"
End If
If optsuspsi.Value Then
rsmod.Fields("suspendido") = "S"
Else
rsmod.Fields("suspendido") = "N"
End If
If optdilsi.Value Then
rsmod.Fields("diligencias") = "S"
Else
rsmod.Fields("diligencias") = "N"
End If
If optjorsi.Value Then
rsmod.Fields("en_jornada") = "S"
Else
rsmod.Fields("en_jornada") = "N"
End If
If Trim(cmbobs.Text) <> "" Then
rsmod.Fields("observ") = UCase(Trim(cmbobs.Text))
Else
rsmod.Fields("observ") = Null
End If
respuesta = MsgBox("¿Desea modificar el registro?", vbYesNo)
If respuesta = vbYes Then
'On Error GoTo err_modificar
Call rsmod.Update
Call MsgBox("REGISTRO MODIFICADO", vbInformation)
Else
Call MsgBox("MODIFICACIÓN CANCELADA", vbInformation)
rsmod.CancelUpdate
End If
If I make try to update just one field Call rsmod.Update ("juicio","S") it works. But I do not want to make it this way because there are a lot of fields to be modified.
On the other hand, I have made this operation (select, open recordset, update) with other tables an it worked.
Thank you
I'm trying to update a row with a recorset but I get the error -2147217864(80040e38) error on updating based on queries. The row to be updated couldn't be found.
However the row is there because I can read the values of the row.
rsmod.ActiveConnection = Inicio.conexion
rsmod.CursorLocation = adUseClient
rsmod.LockType = adLockPessimistic
rsmod.CursorType = adOpenDynamic
rsmod.Source = "SELECT * FROM judprue WHERE " & _
"codigo_p = '" & codigo_ant & "' AND " & _
"fecha_jud = '" & Format(fecha_ant, "dd/mm/yyyy") & "' AND " & _
"juzgado = " & juzgado_ant & " AND " & _
"causa_prod = '" & prod_ant & "' AND " & _
"causa_num = " & num_ant & " AND " & _
"causa_agno = " & año_ant
If juznum_ant <> 0 Then
rsmod.Source = rsmod.Source & " AND juz_num = " & _
juznum_ant
End If
On Error GoTo err_modificar
rsmod.Open
rsmod.Fields("codigo_p") = codigo_key
rsmod.Fields("fecha_jud") = Format(fecha_key, "dd/mm/yyyy")
rsmod.Fields("juzgado") = juzgado_key
If Not IsNull(rsmod.Fields("juz_num")) And (juznum_key <> 0) Then
rsmod.Fields("juz_num") = juznum_key
End If
rsmod.Fields("causa_prod") = Me.prod_key
rsmod.Fields("causa_num") = Me.num_key
rsmod.Fields("causa_agno") = Me.año_key
If mskhora.ClipText <> "" Then
rsmod.Fields("hora") = hora
Else
rsmod.Fields("hora") = Null
End If
If optjuisi.Value Then
rsmod.Fields("juicio") = "S"
Else
rsmod.Fields("juicio") = "N"
End If
If optdijuisi.Value Then
rsmod.Fields("dietas_jud") = "S"
Else
rsmod.Fields("dietas_jud") = "N"
End If
If optdidesi.Value Then
rsmod.Fields("dietas_desp") = "S"
If km <> 0 Then
rsmod.Fields("km") = km
End If
Else
rsmod.Fields("dietas_desp") = "N"
End If
If optsuspsi.Value Then
rsmod.Fields("suspendido") = "S"
Else
rsmod.Fields("suspendido") = "N"
End If
If optdilsi.Value Then
rsmod.Fields("diligencias") = "S"
Else
rsmod.Fields("diligencias") = "N"
End If
If optjorsi.Value Then
rsmod.Fields("en_jornada") = "S"
Else
rsmod.Fields("en_jornada") = "N"
End If
If Trim(cmbobs.Text) <> "" Then
rsmod.Fields("observ") = UCase(Trim(cmbobs.Text))
Else
rsmod.Fields("observ") = Null
End If
respuesta = MsgBox("¿Desea modificar el registro?", vbYesNo)
If respuesta = vbYes Then
'On Error GoTo err_modificar
Call rsmod.Update
Call MsgBox("REGISTRO MODIFICADO", vbInformation)
Else
Call MsgBox("MODIFICACIÓN CANCELADA", vbInformation)
rsmod.CancelUpdate
End If
If I make try to update just one field Call rsmod.Update ("juicio","S") it works. But I do not want to make it this way because there are a lot of fields to be modified.
On the other hand, I have made this operation (select, open recordset, update) with other tables an it worked.
Thank you