Delete records from Subform

AlvaroCity

Registered User.
Local time
Today, 09:08
Joined
Jul 16, 2016
Messages
70
Hello Everyone.

I have a problem with my database. I am trying to delete records from my subform but I cant find the solution for such a simple operation.

I have been trying with code like
Code:
  DoCmd.RunCommand acCmdDeleteRecord
but its been fruitlessly.

To explain the problem in much easier way I link this video.

https://youtu.be/7yDehTLgTtA

Thank you for your help
 
Microsoft made another version of DAO. The DLL you tried to reference in the video is the old one.
Newer versions of Access use the Access Database Engine which is already referenced in your project.

To delete a record the sql would be

Code:
sql = "delete * from [yourtablename] where [youridfield]=" & currentrecordID

To run the sql using ADE (new DAO) against the currently open database you only need

Code:
CurrentDb.Execute sql

To do the same in ADO you would use something like

Code:
CurrentProject.Connection.Execute sql

What problems did you have with RunCommand?
 
I dont know. It doesnt allow me to delete it... maybe I am just doing it wrong.

What code would you use if you put the runcommand?

Thank you for your help
 
The best way to get help is to describe the problem. Just saying "it doesn't work" doesn't help me so it doesn't help you.
Ignoring 90% of my post doesn't make me want to help you.

What code did you try?
What error did you get?
 
To answer your question I would try to avoid any docmd or runcommands or anything like that wherever possible. They tend to be hooks into the Access menu system and, to me, just seem to be dirty work around's.

If you want to modify data use sql.
 
Hello Static

First of all, sorry for my last reply. It was a bit late and I should have answered your post in another better moment.

I have tried to code

Code:
DoCmd.GoToControl Screen.PreviousControl.Name
DoCmd.RunCommand acCmdDeleteRecord

Maybe this is just not the right code for that I should use another one instead.

Thank you for your help and my apologies.
 
I tried
Code:
DoCmd.RunCommand acCmdDeleteRecord

in one of my databases that's similar to your situation and it works. I think at this point it would be easier for us to debug this if you upload your database.
 

Users who are viewing this thread

Back
Top Bottom