Topics Search

Delete a record using VBA code in Access

Delete a record using VBA code in Access
Views: 3677
I want to delete the currently selected record. How do I delete the current record in the form?
Sponsored Links:

Similar posts...

 

Delete Command Button not working on form

Delete Command Button not working on form Icon
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 using a combo box to select record

Delete using a combo box to select record Icon
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?
 

Modify properties of a relationship from VBA

Modify properties of a relationship from VBA Icon
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?
 

access tabel

access tabel Icon
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
 

Vba Code delete&shift up cells- Access 2007

Vba Code delete&shift up cells- Access 2007 Icon
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?
 

Delete Record with related Table & Sub form.

Delete Record with related Table & Sub form. Icon
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.
 

How to cancel/control creating new recs and deletions

How to cancel/control creating new recs and deletions Icon
I am having problems with a table/form. I need everyone to have write access but I need only selected people to have the ability to create or delete a record. One or two people start each record but then several people add to it.

How do I control the create record and delete record in the code using their IDs
 

New Record/Edit/Delete

New Record/Edit/Delete Icon
I am doing a project and I am linking to a access database table. I am writing my own code to connect to data adapter. I have a list of records in a database table and want ot edit one record and update it in the database or create a new record or delete a record but can't get it to work.
 

Record information in a label and disabling buttons by code.

Record information in a label and disabling buttons by code. Icon
How would I go about some VBA code to say "Record X of Y" I know I can do this by showing the Record Selectors in Access but I do not want to, also is it possible to disable my next buttonwhen it gets to Record X of X (5 of 5 - they're the same) and the same for previous button?
 

Copy previous record, VBA

Copy previous record, VBA Icon
I have a form with a subform where we enter new cable references. Most of the time the new record that you put in will be a duplicate of the previous record + 1(on the primary key/cable reference).

What I wish to make is a small vba action that simply copies the previous values from the record above (if it exists and maybe only if there is no values in the field when you enter.)

I have programmed VB a bit but are all new to the syntax in access. Does anybody have a some code for this? or other example code in the same area