How to Validate Access Text Boxes with the Text Property
Question details
The user needs to validate two MS Access text boxes in real-time during editing to enable or disable a form button based on valid date inputs.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Validating text box input in real-time before focus leaves the control to dynamically update a form button's state.
- Observed behavior
- During the Change event, the code reads the previous .Value instead of the newly typed text, preventing proper real-time validation and button state updates.
Familiarize yourself with VBA code in Microsoft Access and ensure you know how to access the property sheet and event procedures for your form controls.
Use the .Text Property in the Change Event
Read the active control's .Text property alongside the inactive control's saved .Value to capture real-time keystrokes.
In Microsoft Access, a text box's .Value property only updates after the control loses focus. To evaluate user input character-by-character as they type, you must use the .Text property within the control's On Change event.
Since the .Text property is only accessible when a control has focus, you need to validate the active control's .Text alongside the other inactive control's saved .Value.
Right-click your Access form in the Navigation Pane and select Design View to edit the form layout.
Select the first date text box. In the Property Sheet, go to the Event tab, click the ellipsis (...) next to 'On Change', and choose Code Builder.
Inside the event procedure, write a VBA script that checks if the active text box's .Text and the second text box's .Value are both valid dates using the IsDate() function.
If both evaluate to true, set the button's .Enabled property to True. Otherwise, set it to False.
Apply the exact same logic to the second text box's On Change event, ensuring you check its .Text against the first text box's .Value.

Looking for a Free Microsoft Office Alternative?
While WPS Office does not include a database management tool like Access, it is a highly capable, free alternative for Word, Excel, and PowerPoint. Enjoy a lightweight suite with excellent format compatibility and a familiar user interface.
- 1. Download the Installer: Visit the official WPS website and download the free WPS Office installer.
- 2. Install the Suite: Run the installer and follow the on-screen prompts to set up the software on your device.
- 3. Open Office Files: Double-click any existing Word, Excel, or PowerPoint document to open it seamlessly in WPS Office.

Frequently Asked Questions
Why isn't the .Value property updating when I type in an Access text box?
In Microsoft Access, the .Value property is only committed and updated when the control loses focus or the record is saved. To capture keystrokes in real-time, you must use the .Text property during the Change event.
Can I check the .Text property of a text box that doesn't have focus?
No. Access throws an error if you try to read the .Text property of a control that does not currently have focus. You can only read the .Text of the active control.
Why use the On Change event instead of After Update?
The After Update event only triggers after the user finishes editing and moves to another control. If you want a button to enable or disable dynamically while the user is still typing, you must use the On Change event.




