How to Fix SLRENF Form Error at TextBox10 in Access VBA
Question details
The user is encountering an SLRENF form error in Microsoft Access VBA at TextBox10 due to a recursive control-clearing event.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A TextBox9 AfterUpdate event clears form controls recursively, removing date values before the VBA code can process them.
- Observed behavior
- The form raises an error at TextBox10 because its value is cleared prematurely and cannot be read as a date variable by the executing code.
Before modifying your VBA code, open your Access form in Design View and verify that the AfterUpdate event properties for TextBox9 and TextBox10 are correctly linked to your respective VBA event procedures.
Use a Static Boolean Flag to Prevent Recursive Execution
Implement a static Boolean variable within the AfterUpdate event to block the code from executing multiple times recursively and clearing the date values prematurely.
When a textbox update event changes other controls, it can inadvertently trigger additional events, causing a recursive loop. By using a Static Boolean flag, you can tell the program to ignore subsequent triggers while the initial event is still processing.
Press ALT + F11 to open the Microsoft Visual Basic for Applications editor and locate the TextBox9_AfterUpdate procedure for your form.
At the very beginning of the procedure, declare a static variable by adding the line: Static bIsUpdating As Boolean.
Immediately below the declaration, add a check to exit the sub if it's already running: If bIsUpdating Then Exit Sub.
Before the block of code that clears the form controls, set the flag to true: bIsUpdating = True.
Validate TextBox10 and TextBox9 using IsDate() before assigning them to Date variables. Finally, set bIsUpdating = False at the end of the procedure so future updates can run.

Switch to WPS Office for Seamless Macro and Data Management
While Microsoft Access handles complex databases, WPS Office offers a powerful, lightweight, and free alternative for managing data, forms, and macros through WPS Spreadsheet. Enjoy familiar VBA environments and high compatibility without the heavy subscription fees.
- 1. Download WPS Office: Visit the official WPS Office website to download and install the free suite on your device.
- 2. Enable Developer Tools: Open WPS Spreadsheet, navigate to the Options menu, and enable the Developer tab to access the built-in VBA editor.
- 3. Manage Data and Macros: Import your existing macro-enabled workbooks to continue managing your data and forms seamlessly.

Frequently Asked Questions
Why does my VBA form clear controls recursively?
Recursive clearing happens when a VBA event procedure, like an AfterUpdate event, changes the value of another control, which in turn triggers its own update event, creating an infinite loop or premature data wiping.
How do I validate a textbox date in VBA before processing?
You can use the IsDate() function in your VBA code to check if the textbox contains a valid date format before assigning it to a Date-type variable, preventing type mismatch errors.
What is a Static variable in VBA and how does it help?
A Static variable retains its value between calls to the procedure. It is highly useful as a flag to detect if the procedure is already running, thereby blocking recursive or duplicate executions within the same form session.




