Avatar of Evert Jor
Evert Jor
Flag 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.
Microsoft ApplicationsMicrosoft OfficeMicrosoft Access

Avatar of undefined
Last Comment
Evert Jor

8/22/2022 - Mon
peter57r

"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.
mbizup

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.
Hamed Nasr

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?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Evert Jor

ASKER
Hi.

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.
ASKER CERTIFIED SOLUTION
mbizup

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Hamed Nasr

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.
Evert Jor

ASKER
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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.