logo
search
VBA & Macro Problems

How to Fix SLRENF Form Error at TextBox10 in Access VBA

Steve KSteve K Sep 25, 2026 869 views

Question details

The user is encountering an SLRENF form error in Microsoft Access VBA at TextBox10 due to a recursive control-clearing event.

How to Fix SLRENF Form Error at TextBox10 in Access VBA
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press ALT + F11 to open the Microsoft Visual Basic for Applications editor and locate the TextBox9_AfterUpdate procedure for your form.

2
Declare a Static Boolean Flag

At the very beginning of the procedure, declare a static variable by adding the line: Static bIsUpdating As Boolean.

3
Add an Exit Condition

Immediately below the declaration, add a check to exit the sub if it's already running: If bIsUpdating Then Exit Sub.

4
Set the Flag to True

Before the block of code that clears the form controls, set the flag to true: bIsUpdating = True.

5
Reset the Flag and Validate Data

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.

Use a Static Boolean Flag to Prevent Recursive Execution
Validation Tip: Always validate user inputs from textboxes using the IsDate() function before passing them to Date-type variables to prevent type mismatch errors.
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS Office website to download and install the free suite on your device.
  2. 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. 3. Manage Data and Macros: Import your existing macro-enabled workbooks to continue managing your data and forms seamlessly.
Highly compatible with Microsoft Excel (.xlsx, .xls) and macro-enabled formats (.xlsm).Advanced spreadsheet functionalities for managing and analyzing large datasets.Built-in VBA editor for automating tasks and creating custom data entry forms.Completely free and lightweight alternative to Microsoft Office.
microsoft office alternative - wps office

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.