Help with deleting record in subform

Flora2021

New Member
Joined
Apr 28, 2022
Messages
44
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,
 
Before record delete
Application.DisplayAlerts = False
Reset to True after record deletion
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Application.DisplayAlerts = False
As noted, this is an Access forum. Access has no .DisplayAlerts property AFAIK, but it does have SetWarnigs in vba.
I don't use macros either but suspect that your problem is the use of Undo method. That undoes changes to a record. Whether or not that includes deletion I don't know. I'll see if I can download an open the file.

EDIT- Actually, maybe I'll wait for OP to try removing undo. I don't see why it would be there regardless if the goal is to delete a record. There should be nothing to undo. So is the button exclusively for deleting, or is it for undoing changes to a record too, thereby restoring previous values?
 
Upvote 0
My mistake, I was assuming excel when looking at the unanswered posts
My VBA in access is limited and I als ways say a lot of @£#¥ words when I do try things in access VBA 😉
 
Upvote 0
As noted, this is an Access forum. Access has no .DisplayAlerts property AFAIK, but it does have SetWarnigs in vba.
I don't use macros either but suspect that your problem is the use of Undo method. That undoes changes to a record. Whether or not that includes deletion I don't know. I'll see if I can download an open the file.

EDIT- Actually, maybe I'll wait for OP to try removing undo. I don't see why it would be there regardless if the goal is to delete a record. There should be nothing to undo. So is the button exclusively for deleting, or is it for undoing changes to a record too, thereby restoring previous values?
Hi, the goal is to completely remove the record not just undo data. :) Thanks!
 
Upvote 0
I made a few changes but can't test further as I have to go out for the afternoon. I think the important change would be your form recordsource. Try it with
SELECT [Issue Log].* FROM [Issue Log];
 
Upvote 0
I made a few changes but can't test further as I have to go out for the afternoon. I think the important change would be your form recordsource. Try it with
SELECT [Issue Log].* FROM [Issue Log];
Didnt work :( I really don't know what the issue is.
 
Upvote 0
Not sure I can recall all changes, and I'll tell you, embedded macros are a real pain in the patookas. You can only look at one at a time as they're entirely modal and you can't output the actions in any sort of text way. So how about ditch the embedded macro, click on the ellipses instead and paste this between the resulting Sub / End Sub lines:
VBA Code:
Select Case True
     Case Me.NewRecord And Me.Dirty
          Me.Undo
     Case Me.NewRecord And Me.Dirty = False
          Beep
     Case Me.NewRecord = False
          DoCmd.RunCommand acCmdDeleteRecord
          Me.Requery 'or use me.refresh if that causes issue
End Select
If you want to do away with the warning we can do that after you get something working. If you don't like how the form jumps back to the 1st record, remove Me.Requery or change it to Me.Refresh. If there isn't likely to be any changes to any other fields (such as needing to refresh calculations) you can do without it altogether.
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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