Delete a record using VBA code in Access
Thank you for taking the time to report an issue.
What's wrong... Please write below.
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:
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?
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?
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?
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 do I control the create record and delete record in the code using their IDs
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