Re: Access Crashes with ADO Delete Record Command



Yes, the syntax is AnyOpenRecordSet.Requery
Since rst is closed, and there is very little code, it might be
rst2.Requery. But rst2 is not opened in code shown.

/Henning

"JP Bless" <jp3BlessNoSpam@xxxxxxxxxxx> skrev i meddelandet
news:emw6%23jMMHHA.992@xxxxxxxxxxxxxxxxxxxxxxx
me.requery '!!!!!!!!!!!!!! Code fails here

This will fail if you are using VB: There is no intrinsic me.requery
function/command. You probably meant me.Refresh to refresh your recordset
after deleteing a record. The "shutdown" is probably because there is no
error handler in your function/sub.



"jamie" <jamiedora@xxxxxxxxx> wrote in message
news:1167932116.570582.309290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To anyone who can help:

I have a form, in data*** view, I wrote code (in ADO), listed below,
to delete a given record. The code is placed in a module, and called
by simmilar forms. For this paticular form, when I initate the code,
the record is deleted and the application crashses (shuts down without
warning). The table is linked.

When I execute the command in debug mode, the following error (Record
Is Deleted, 3167) is recieved, when I press end the application ends.
When I bypass the requerry cmd, and refresh the form mannually, I get
the same error.

Thus far, I have tried to compact/repair both tables; rebuild the form,
rebuild the table. I even deleted all table relationships.

For all my attempts, I have had no luck. - Thanks in advance, to anyone
who can assit

'***** Code Snipit *****
Dim db As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rst2 As ADODB.Recordset
Dim msgResult, ItemCurrent As Long
Dim lngRelatedID As Variant

'-- Constants --
SQLCodeA = "SELECT CB_MaterialProject.ID " _
& "From CB_MaterialProject " _
& "WHERE CB_MaterialProject.ID = " & intID

'-- Objects --
Set db = CurrentProject.Connection
Set rst = New ADODB.Recordset

DoCmd.close acForm, strFormName, acSaveNo 'Close form to avoid errors

'-- Open Database --
rst.Open SQLCodeA, db, adOpenKeyset, adLockOptimistic
If rst.EOF Then Exit Sub
msgResult = MsgBox("Do you wish to delete Item ?", vbInformation +
vbYesNo)
If msgResult = vbYes Then
rst.Delete (adAffectCurrent)
rst.Update
rst.close
end If

me.requery '!!!!!!!!!!!!!! Code fails here





.


Loading