VBA doesn't work and no errors popup

Arcanant

New member
Local time
Today, 15:04
Joined
Jun 4, 2022
Messages
12
I am trying to emulate the "delete" keyboard button in vba to delete a selected record from a subform,
and I am trying to make this happen after running an update Query.

Code:
Private Sub deletebtn_Click()


CurrentDb.Execute ("qrupdateqty")
Call DoCmd.RunCommand(Command:=acCmdDeleteRecord)
Forms!frmCustomers!subfShowSales.Requery
Forms!frmEditSales!subfListProducts.Requery


End Sub


But nothing happens, literally, not even warnings. I tried to do it with DoCmd.RunCommand acCmdDeleteRecord as Access suggests but I am not getting any results.
Any help would be very much appreciated.
 
Are you saying no record gets deleted?
 
Take the parentheses off the CurrentDB.Execute command. They change the nature of the implied call.

You can also simplify the next line using DoCmd.RunCommand acCmdDeleteRecord as Access documentation suggests. Though syntax-wise, your usage was not wrong. Just maybe a bit wordy.

However, I would not be sure which record would be deleted here. You would be less worried about an ambiguous selection if you could just define a DELETE query to do the selection AND the record deletion simultaneously. What is the SQL of your qrupdateqty query?
 
Hello and thanks for your replies.

I actually went ahead and made a Delete Query with criteria and that works for me. Thank you for your attention and replies.
 
I just tried that long winded way to delete a record, and received the warning that 1 record is about to be delete?
Is the recordsource even editable?
 

Users who are viewing this thread

Back
Top Bottom