none
Disabled Button Not Greyed Out RRS feed

  • Question

  • Experts -

    I have some simple code to disable a button on a form:

    If int = 0 then
      me.button.enabled = false
    else 
      me.button.enabled = true
    end if
    

    For some reason this is disabling the button without greying it out, so it still appears to be enabled.

    Any idea why this is?

    Thanks!


    Bonediggler

    Wednesday, February 22, 2017 4:54 PM

All replies

  • Hi,

    Without being able to look at your form, the only guess I could make is maybe the code is referring to a different button?

    Just a thought...

    Wednesday, February 22, 2017 5:20 PM
  • How are you verifying that the button is disabled without it being greyed out?  Are you able to click on it?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Wednesday, February 22, 2017 6:16 PM
  • It is disabled because I cannot click on it.  Just not greyed out.

    The same code is working for a different button on another form.  Never seen this before......


    Bonediggler

    Wednesday, February 22, 2017 8:21 PM
  • Can you post some screenshots? Form and design view, please. Thanks.
    Wednesday, February 22, 2017 8:37 PM
  • Hello theDBguy -

    Unfortunately no - due to company policy.


    Bonediggler

    Wednesday, February 22, 2017 9:54 PM
  • Okay, are you overlaying controls on top of other controls? Would it be possible you're looking at something totally different than what the code is changing?
    Wednesday, February 22, 2017 10:18 PM
  • 1) No - just confirmed there is only one button there.

    2) No - changing the value of "int" from the code above toggles the offending button between enabled/disabled.  Just unfortunately not blue/grey.


    Bonediggler

    Wednesday, February 22, 2017 10:58 PM
  • Hi Bonediggler,

    First of all try to change the variable name from int to any other name.

    when I try to test it gave me an error.

    after I made change it works correctly.

    if that doesn't solve your issue then try to delete that button and create a new button and make a test with that.

    if that also does not solve your issue then try to create new form for testing purpose place the button and test whether it work or not.

    if that work then there is some thing wrong with your form or with your button.

    try to check whether it causes by your code or something get corrupted.

    if it causes by your code then you need to correct it to solve the issue.

    if the issue is not caused by your code then try to Compact and Repair your database and test again whether the issue is solved or not.

    let us know about your testing results.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 23, 2017 1:37 AM
    Moderator
  • Deepak - none of this is working.  Looks like I am going to have to go with a malfunctioning button!

    Thanks for the ideas.


    Bonediggler

    Thursday, February 23, 2017 3:08 PM
  • Bonediggler -

    I've been racking my brains over this, and I have a question:  is the button in question a command button, or is it a toggle button?  I can imagine a scenario where it makes a difference.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Thursday, February 23, 2017 5:11 PM
  • Yes  - quite a strange case indeed.  It is a command button.

    Bonediggler

    Thursday, February 23, 2017 5:14 PM
  • Deepak - none of this is working.  Looks like I am going to have to go with a malfunctioning button!

    Thanks for the ideas.


    Bonediggler

    Hi,

    What happens if you create a new button on the same form or if you create a new form? Do you still get the same behavior? Just wondering if the button or the form is corrupted.

    Just a thought...

    Thursday, February 23, 2017 5:22 PM
  • Can you create a new database, import into it just the form in question, cut out anything unnecessary, and verify that it still doesn't work properly?  And if that is the case, can you post that database for inspection on a file-sharing service where we can download it for inspection, or e-mail it directly to me?  You can get my e-mail address from my website.

    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Thursday, February 23, 2017 5:28 PM
  • You could augment the code so that it conditionally sets the button's ForeColor property as well as its Enabled property.  With some colours it's less apparent that the control is disabled than with others.

    Ken Sheridan, Stafford, England

    Thursday, February 23, 2017 6:15 PM