Control Updating Records using a Form - MS Access
Posted on 2016-10-19
I have an Access database with a bound form for adding records to a table. The form has a bunch of textboxes and comboboxes on it for entering and selecting data. Once all required boxes are populated, the user clicks a command button to add a record.
Before a record can be added, many checks for valid data in the boxes are performed under the on click event of the ‘add record’ command button. Some of the checks include comparing what was entered into one box with what was entered into another box; as there are restrictions on what combinations can be used.
I’m now trying to add record update capability to the form. The problem is in its current state, I’m able to go into any box I want to, make a change and that change is automatically saved. That’s no good; as it bypasses all of the data checks that are performed when a record is added.
Ideally I’d only like changes made to values in boxes to be saved if I click a command button. If the command button is not clicked, then the changes don’t get saved. This way, I can run all of the same code in the update button's on click event as I do for the add button's on click event
So, for example, let’s say an existing record is displayed through the various boxes on the form. I then make changes to some of the values in the boxes but DO NOT click the ‘update record’ command button. If I then navigate to a different record and then come back to the record in question, I’d like to see that the values reverted back to what they originally were. Or…if I change values but do not click the update button and then close the application, if I open it back up, I’d like to see the original values still there. In other words, I’m trying to control updates through the use of an ‘update’ command button. How can I accomplish this? Thanks.