Link to home
Start Free TrialLog in
Avatar of Evert Jor
Evert JorFlag for Norway

asked on

Unable to disable and enable form controls

I have an unbound textbox which is updated with data from another control.
I also have a button that I need to disable when data is updated in the textbox.

I'm able to do that with an on event procedure. As it is now I have to click the texbox with the updated data in order for the button to be disabled.

How do I go about disabling the button when the textbox is updated?
I've tried the "On dirty"-event, but that doesn't work and "On Change"-event but that doesn't work.

I'm using Access 2010. Any advice? Do I have to do something specific in VBA to get this to work? I just use controlname.enabled = False.
Avatar of peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

"I have an unbound textbox which is updated with data from another control."

Add the 'button.enabled = false' command to the code you are using to update the textbox.
In addition to what Pete has said, the Change and After Update events are triggered by user actions -- so if this textbox is being updated by another control, those event procedures will not fire and your code needs to in some event that you know *will* fire.

If this textbox is being updated via code, the best place to lock the command button would be in that same block of code - as Pete mentioned.

If rather than using VBA, you are updating the textbox through a control source formula such as
 = [TextBox1] * Qty

You'll have to lock the command button through an event that you know will fire - for example the After Update event of a control that the user is actually entering data in, the form's Current Event - which fires as the user moves from record to record, etc.
txt1 has no value, btn1 enabled.

txt1 modified, btn1 disabled. Is tx1 modified from txt0 after update? then you can disable btn1 there.

When btn1 is enabled again?
Avatar of Evert Jor



I need to enable and disable buttons for example when backend scripts have been started and are being performed. Setting the enable and disable in VBA doesn't seem to work. I'm using Access 2010, Windows 8.

So: I need that to prevent multiple instances of the same backend updating procedure to get triggered once it has been started.

It would be like having a wife asking you every minute why you still aren't back from the grocery store even when you are back home again with the bags and she still can't see it.

Just an example when the user doesn't necessarily know what is happening in the software. (I could have used a husband as an example also - just wanted to explain why that functionality is necessary).

Still waiting for som useful suggestions to this problem.
Avatar of mbizup
Flag of Kazakhstan image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Don't assume we remember the discussion more than a day or two. You responded one week after my comment. That makes it time consuming to get on track with the question again.

Now give a direct example like:
On form you have txt0, text1, btn0 , and so on
user enters value abc in txt0, and form shows
But I expect such things to happen.
I actually have several DoEvent-scripts like you suggest. The problem I'm having is that the button doesn't update with the True and False to Enable and Disable it on the form through VBA.

So for example if I use a Dlookup to get a count in some query and want to enable the button if the count is >= 0 that doesn't work.