Help with deleting record in subform

Flora2021

Board Regular
Joined
Apr 28, 2022
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a simple subform that relates back to a single table.
I created a simple button from the wizard to be able to delete a record.
Well it works fine to delete in the subform but it remains in the table.
If I view it in the table and then go back into the subform, the record then pops back up in the subform.
How do I use this delete button to remove the record from both the table and subform? Thanks,
 
How do you attach a file? I thought we could only attach images here?
When I delete it, it looks like it temporarily removes the record from the form. It gives a prompt about being sure if I want to delete the record, and then If you delete record say id 106, and then you toggle the forward and backwards record buttons it goes from 105 to 107 however, if you then open the table that its linked back to the record is still there then if you open the form again record 106 is back. It is very strange.
 

Attachments

  • 6.PNG
    6.PNG
    9.1 KB · Views: 6
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I just used the wizard to create pretty much the same macro.
When using the button it warns me I am about to delete a record? Do you get that warning?
When I select OK, the record is deleted, but you need to refresh the form for the record count to be updated.

Edit: Hmm, you appear to be correct re uploading a file?, just used to be able to do this on other forums. Sorry. :(
Perhaps upload to Google drive and give access? (no pun intended :) )

Just had a thought?, is it linked to any other records?, ie a parent of another table's records?
If so, do you have Cascade Delete set for the relationship?
 
Upvote 0
I just used the wizard to create pretty much the same macro.
When using the button it warns me I am about to delete a record? Do you get that warning?
When I select OK, the record is deleted, but you need to refresh the form for the record count to be updated.

Edit: Hmm, you appear to be correct re uploading a file?, just used to be able to do this on other forums. Sorry. :(
Perhaps upload to Google drive and give access? (no pun intended :) )

Just had a thought?, is it linked to any other records?, ie a parent of another table's records?
If so, do you have Cascade Delete set for the relationship?
Hi, yes I get the prompt. I posted screenshot above. Its just directly tied back to the main table. There are no queries or other relationships or queries or filters. :) I can see about uploading to google drive and seeing if that would work. I deleted the record, and refreshed all but the record popped back up LOL. It is like it refuses to actually be removed from the table.
 
Upvote 0
Hi, yes I get the prompt. I posted screenshot above. Its just directly tied back to the main table. There are no queries or other relationships or queries or filters. :) I can see about uploading to google drive and seeing if that would work. I deleted the record, and refreshed all but the record popped back up LOL. It is like it refuses to actually be removed from the table.
Well I can confirm the wizard macro does work, so there must be some issue with your DB?
Have you tried for any other record?, just trying to troubleshoot here?

DB is not read only is it?
 
Upvote 0
Well I can confirm the wizard macro does work, so there must be some issue with your DB?
Have you tried for any other record?, just trying to troubleshoot here?

DB is not read only is it?
Yeah it is not read only and I tried other records and same thing. It appears to delete but then when you refresh it, it comes back and does not get deleted from table.
I am trying to attach link for file here. Access Database
 
Upvote 0
Yes, as I suspected. I am unable to open it, due to having 2007. Hopefully someone else might take a look. Sorry. :(
Are you able to save in 2007 format? What version of Acess are you using?
 
Upvote 0
Try this command in the immediate window

Code:
DoCmd.RunCommand acCmdDeleteRecord
Does that actually delete a record.?

If so, use VBA code instead
Code:
DoCmd.SetWarnings False
If MsgBox("Are you sure you want to abandon changes to this record?", vbExclamation + vbYesNo, "LogBook 2002") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings True
End If

NB that code will hide the warning, so adjust to suit. However you get the warning via the MSGBOX instead.

Not my code, just copied from a quick google.
 
Upvote 0
Yes, as I suspected. I am unable to open it, due to having 2007. Hopefully someone else might take a look. Sorry. :(
Are you able to save in 2007 format? What version of Acess are you using?
version 365. :( I didnt see an option to save as 2007
Try this command in the immediate window

Code:
DoCmd.RunCommand acCmdDeleteRecord
Does that actually delete a record.?

If so, use VBA code instead
Code:
DoCmd.SetWarnings False
If MsgBox("Are you sure you want to abandon changes to this record?", vbExclamation + vbYesNo, "LogBook 2002") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings True
End If

NB that code will hide the warning, so adjust to suit. However you get the warning via the MSGBOX instead.

Not my code, just copied from a quick google.
Tried it and same thing as before. It appeared to work and then the record magically came back :(
 
Upvote 0
Need to wait for someone who is able to open it to pick up the thread.

Can you use the following link?

File has to be Read only surely? Check it's properties in explorer.
I get a warning if I set the file to Read Only.

Create a new db, add 1 table and one record. Can you delete that.
Also try deleting direct from table.
 
Upvote 0
Need to wait for someone who is able to open it to pick up the thread.

Can you use the following link?

File has to be Read only surely? Check it's properties in explorer.
I get a warning if I set the file to Read Only.

Create a new db, add 1 table and one record. Can you delete that.
Also try deleting direct from table.
I can see link and it is not read only. I can make edits and change codes make changes to the table in design view etc.
 

Attachments

  • 7.PNG
    7.PNG
    8.3 KB · Views: 6
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top