I have one form to edit the records of a single table. Everything on it is working as expected except for one text field which is reverting the changes done to the record when exiting the form when I empty it through VBA code, not when I manually delete its content on the form, though.
This is the setup. The form has 25-30 fields of various types (mostly text boxes, check boxes, and a couple of attachment fields) each corresponding to a field on the table. They can be considered as 4 groups of fields, that I wanted to activate or deactivate through 4 main checkboxes. If the main checkbox is activated, all the controls corresponding to that 'category' are enabled. If it is unchecked, all controls are disabled. For commodity, I want to reset the value of all those controls, so if the user unchecks the main checkbox and some related fields have data it warns the user and, upon confirmation, it erases the data and disables the controls.
This is working for every field on the form except for a simple textbox. The textbox is exactly the same as some others who are working OK. It's just a textbox with an input mask and a validation rule to ensure it has a certain fixed length. The way I go to delete the data and disable the textboxes is the following:
The main checkbox for this particular textbox handles another 2 identical textboxes, three checkboxes and two attachment fields. If I comment the two lines for the problematic textbox, everything updates right. If I leave them on, controls lose their value and are disabled, but upon exiting the form all changes done are rolled back and reverted to their previous value. Deleting the textbox's content from the form manually doesn't cause this error upon exiting.Code:Me.textbox = "" Me.textbox.Enabled = False
I've gone through the code line by line and no error is thrown (neither when updating nor when exiting the form). The field has an after update macro to keep a history of past values, but so does every other field and they are not causing this behaviour.
Any general idea what might be the problem? Because I'm at a total loss.
Thank you so much!