Problem with deletion (1 Viewer)

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:41
Joined
Sep 12, 2006
Messages
15,660
I am really stuck on this

I have an order form with a subform showing the order lines.
I added conditional formatting today to change the presentation of an unbound empty text box, to provide a highlighted backcolor in some cases.

Because I want to control the activity of a delete function, I have disabled edits and deletes, and added a button to delete a row.
This entire process is actually running correctly in a different form. I just tried it, and it worked correctly. I actually cloned that form, and modified it to produce this form.

So I have this process now on the "Delete Line" button in the subform.
Code:
If MsgBox("Please confirm you wish to delete the selected line ", vbQuestion + vbYesNo + vbDefaultButton2, "Confirm") = vbNo Then
        Exit Sub
    End If
  
    On Error GoTo fail
    DeletePressed = True 'this is a variable in the subform to indicate that the delete process is active

    RunCommand acCmdDeleteRecord
      
    MsgBox "The record has been deleted"
   'the record disappears from the subform


    MsgBox "The Delete Button Process is complete"
    DeletePressed = False
  
     MsgBox "Show recordsource now "
     DoCmd.OpenQuery Me.RecordSource 'this is the recordsource of the subform.

Now the delete function is hanging on this final instruction.
I have to stop access in task manager, and then I find the deleted item is not really deleted.
Actually I can see that the records are not yet displayed in the subform when I try to show the query

What I did is added 2 new lines which are highlighted by the conditional formatting.

I forget exactly what I did, but while try different things, I had an error that a certain process can't be carried out while a transaction is running. I have no idea what transaction might be running.

The only thing I can think now is that perhaps somewhere in this subform, something is trying to use the original subform query, and not the new subform query. Could that produce a "transaction error" code. Alternatively, could I inadvertently be actually running a transaction without meaning to? How could I tell?
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:41
Joined
Sep 12, 2006
Messages
15,660
Well, I've got round it, by writing a single SQL delete statement, running that, and then requerying the subform, which seems to work.
No idea why the original method failed.
 

Users who are viewing this thread

Top Bottom