Results 1 to 4 of 4
  1. #1
    bbrazeau is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    101

    Setting the Enabled property of Command button conditionally

    I have a command button on a form that uses info from a textbox and a combobox. I need to make sure there are values in the controls. Could someone show me how I can set the Enabled property of the command button to be false unless the other 2 controls have data? I'd like to do htis with macro commands as I'm not to well versed in VBA. Thank You.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    The easiest way to do what you're trying to do is through VBA.

    It is not complex at all - and it might give you a really good opportunity to dip your toes in the water.

    You'll get plenty of help here with VBA.

  3. #3
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    The great thing about VBA is that its what I call programming by multiple choice . For your issue try an if statement. In the example below when you type the me. (don't forget the dot) Access will show you all the name of the controls in a drop down list, just type the first letter of the name of your textbox or combo box. i.e. If me.textbox = [enter your info here] And me.combobox = [enter your info here] Then me.button.enabled = false.

    Try the me. a few times - it's fun!! (oh replace textbox with the name of your text box and same for combo box and button).

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'd take Tina's suggestion

    In the ON EXIT property of your two required fields have the code:

    Code:
    if not isnull(me.firstfield) and not isnull(me.secondfield) then
       me.buttonname.enabled = true
    else
       me.buttonname.enabled = false
    endif
    where firstfield, secondfield and button name are all the names of the objects on your form

Please reply to this thread with any new information or opinions.

Similar Threads

  1. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 AM
  2. Command Button
    By BLD21 in forum Access
    Replies: 2
    Last Post: 05-02-2011, 04:47 PM
  3. Replies: 1
    Last Post: 08-12-2010, 10:33 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Replies: 4
    Last Post: 09-10-2009, 03:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums