Delete a record using VBA code in Access

I want to delete the currently selected record. How do I delete the current record in the form?
I have 3 table.and every table have to relation.
2.i do QRY for 3 table link in from
3.i make from form for add, edit , and delete

my Qustion
1.when I delete in from but table not delete?
** I'm enforce and cascade delete related but can't delete it
in step 1 can't delete it I will do step 2
2.i make new button in code VBA

Private Sub Command123_Click()
DoCmd.RunSQL "Delete * from tbl_com"
Me.Requery
End Sub

it delete all record in table

I want delete 1 record in from and intable

Sponsored Links:

Related Topics

delete one record by from
I have 3 table.and every table have to relation.
2.i do QRY for 3 table link in from
3.i make from form for add, edit , and delete

my Qustion
1.when I delete in from but table not delete?
** I'm enforce and cascade delete related but can't delete it
in step 1 can't delete it I will do step 2
2.i make new button in code VBA

Private Sub Command123_Click()
DoCmd.RunSQL "Delete * from tbl_com"
Me.Requery
End Sub

it delete all record in table

I want delete 1 record in from and intable


Delete Record and Subform Records
I have searched the forum for the answer to this question but have not found the solution yet.
I would like to get rid of as many macros in my database as possible and rely on the VBA. I have a button to delete a record on my mainform, which I have put the following code:

Private Sub cmdDeleteSupplier_Click()
If (MsgBox("Deleting a supplier record will permanently delete it. Are you sure you want to delete?", vbYesNo, "Delete Confirmation")) = vbYes Then
If Me.Dirty Then
Me.Undo
DoCmd.SetWarnings False
If Not Me.NewRecord Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End If
End If
MsgBox "The supplier was successfully deleted.", , "Delete Confirmation"
End If End Sub

I have tried this code with a normal form and it does seem to work but my form has 3 subforms in it on tabbed pages.
My question is how do I get the code to work and delete the record including the other information referenced in the subforms? How do I select this info in


How to delete all records in a table
I an about to write some VBA code, where following some procedures, I will want to delete all record from a table to start fresh the next time I run the code.


Command button issue
I am trying to set up a command button in my form that when clicked will delete the record from my form and append it to an archive table. I have tried doing this via VBA and it works but it takes forever to run. So I have tried to set up a macro to do this, which also works but it requires you to click the button, go to the next record, go back to the desired record and click the button again (works much faster than the VBA code). The macro does the following once clicked it first sets the value of the delete field to delete and then runs the append query then runs the delete query (for records with a value of delete in the delete field). I am not sure why I have to change records and click the button again. Does anyone know of a way to do accomplish this task without changing records


Running Code based on User's Response to delete macro
I am using the standard delete macro that the access button creator has. I added a line to the macro that runs a vba code segment, but I only want this to run if the user presses yes to deleting the record. Is there a condition that I can write that will allow me to determine if the user pressed yes or no and run the code accordingly?


VBA delete current record continuous form
I have a button on a continuous form that appears next to each record on the form. I want it to delete the record on the same row from the source table using vba. I've tried Recordset.Delete, and I'm getting error messages.


VBA delete current record continuous form
I have a button on a continuous form that appears next to each record on the form. I want it to delete the record on the same row from the source table using vba. I've tried Recordset.Delete, and I'm getting error messages.


Delete Record and have combobox update
It's me again with another relatively simple access issue. I have a button that is set to delete a record, then refresh the list of records in a combobox; however, for some odd reason it takes two or three attempts to delete the actual record because it keeps showing up, and when it does delete it shows up in the combobox until you try to delete again, at which point you get a debug error saying that the record has been deleted


Delete Command Button not working on form
I have a Delete Command Button on a form which does not appear to be working properly.

I originally had a delete button macro created by the command button wizard and it seemed to be functioning properly. from the form it would ask if you want to delete the record permanently. If I chose yes, it would appear to delete it, meaning that if I were to search for the record to verify it would say that the record does not exist. Upon closing the form and viewing the table, the record would not actually be deleted and would then be back on the form when I would reopen it.

So, I browsed through the discussion board and found a suggestion on a couple of posts and tried that as well creating the delete button in the code builder using the following code:


Delete continuous form record
I have a button in my continuous form that shows up next to each record. I want this button to delete the record next to it with the Recordset.Delete code. Sometimes it works, and other times it says a current record is not selected. What can I added to the code to make sure that it selects the record it is next to?


Delete continuous form record
I have a button in my continuous form that shows up next to each record. I want this button to delete the record next to it with the Recordset.Delete code. Sometimes it works, and other times it says a current record is not selected.

What can I added to the code to make sure that it selects the record it is next to?


Delete using a combo box to select record
I am new to vba and have started my own crash course of trial and error.

Currently, I am using an unbound form to house a combobox, a delete button, and a create button.

The problem I face is with the delete button. The combobox uses a row source from a simple table. I would like to select an item in the comboboxand hit the delete button to delete that record.

I suspect it'll have to be done with DAO?


Vba Code delete&shift up cells- Access 2007
it's the first time I write here.
I have a problem with Access 2007.
I am not a VBA-expert, so you can better understand my difficulties.
I am trying to create, in access, a report based on excel documents. Once it will be finished, the report should display specific cells of any excel documents imported into access.
My actual problem concerns a filtered table I have created in access: I should produce the command (very simple in Excel) to delete a cell in a column and shift up all the cells in the same column. after, I should create text boxes, taking only certain cells from the table, and displaying their contents into the report.
Now, how can I do? Do you know which is the VBA code to delete and shift up in Access?


Vba Code delete&shift up cells- Access 2007
it's the first time I write here.
I have a problem with Access 2007.
I am not a VBA-expert, so you can better understand my difficulties.
I am trying to create, in access, a report based on excel documents. Once it will be finished, the report should display specific cells of any excel documents imported into access.
My actual problem concerns a filtered table I have created in access: I should produce the command (very simple in Excel) to delete a cell in a column and shift up all the cells in the same column. after, I should create text boxes, taking only certain cells from the table, and displaying their contents into the report.
Now, how can I do? Do you know which is the VBA code to delete and shift up in Access


access tabel
I am using this code for import excel file into table when I use this code its delete table but I don't want to delete other tables and when I import excel files message will display filed name not found how I know which file name fields are wrong how to fix it. I know this red highlighted code delete table I just want to delete record from specification table only


Modify properties of a relationship from VBA
I have an Access 2007 database. In it, I have two related tables with a relationship that has Referential Integrity enabled. In a single instance, I want to enable Cascade Delete so thatall related records in a particular table can be deleted when the primary record is deleted.

Can I modify the property of the relationship from VBA to enable Cascade Delete on this one relationship, carry out the delete operation and then disable the Cascade Delete again?


Cannot delete VBA References
In an attempt to resolve a query compile error it has been suggested that I delete and reselect various VBA references. I can delete some but not the following:

Microsoft Access 14.0 Object Library
Visual Basic For Applications

It tells me that they are in use and so cannot be deleted.

I have created a new empty database and tried to delete them and I get the same error message.


Suppress delete record confirmation
I am having this problem in an Access 2010 web database. I have a macro set to delete a record but when it does, a delete confirmation message comes up. Even worse, if the user selects yes to delete, an action failed error (#2950) pops up. I would like to suppress the message but in the new macro language I don't see where there is an option to do so. Since it is a web database I can't use VBA. Does anyone have a solution?


Delete Record with related Table & Sub form.
I am trying to delete a record but it gives me runtime error 3200 saying have related Subform & Tables.

I require a code to delete a record through a cmd button deleting only the current record with the related record in subform & tables.

I think code needs to be put up in onClick Event

Also would like to know how to clear all the data to start entering a fresh data.


Vba Code delete&shift up cells- Access 2007
I have a problem with Access 2007.
so you can better understand my difficulties. I am trying to create, in access, a report based on excel documents. Once it will be finished, the report should display specific cells of any excel documents imported into access.
My actual problem concerns a filtered table I have created in access: I should produce the command (very simple in Excel) to delete a cell in a column and shift up all the cells in the same column.

after, I should create text boxes, taking only certain cells from the table, and displaying their contents into the report.
Now, how can I do? Do you know which is the VBA code to delete and shift up in Access?