Results 1 to 5 of 5
  1. #1
    rogerdavid is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3

    setProperty "enabled" not working for second onClick?

    Hi,

    I have a form for creating a new database record for a list of "components".

    One button "add_component" adds a new record.
    One text input "component_input" allows you to enter in the "name" of the component.
    One button "save_component" saves the record.

    The component_input and save_component have their default "enabled" property set to "No" in their properties list.

    I only want the component_input and save_component form objects to be enabled once the "add_component" button has been clicked. Once the "save_component" button is clicked, I want them to return to being disabled. This will prevent any accidental over-writing of records.

    I have used "build event" for the "add_component" button...

    Code:
    if [macroError] <> 0 then
     ## errorMessage here ##
    else
    
     setProperty
      control name: component_input
      property: enabled
      value: True
    
    setProperty
      control name: save_component
      property: enabled
      value: True
    
    end if
    And then I have used "build event" for the "save_component" button...

    Code:
    if [macroError] <> 0 then
     ## errorMessage here ##
    else
     setProperty
      control name: component_input
      property: enabled
      value: False
    setProperty
      control name: save_component
      property: enabled
      value: False
    end if
    Now, this works when add_component is first clicked, however when I click save_component neither component_input or save_component become disabled again.

    Any idea where I'm going wrong?

    Cheers!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,467
    Is that macro code instead of VBA? I use only VBA.

    Can't disable save_component because it has focus. Need to move focus elsewhere first.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rogerdavid is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3
    Its the wizard type set up when you click "Build Event" and it gives you a whole heap of dropdown boxes to choose from that contain the various actions etc.

    I'm new to VBA, how do I program it with just VBA? I'm pretty handy at VBA with excel, just never used access before, I've been trying to workout how to get the VBA editor for the forms etc. Maybe that's a question for another thread?

    In any case - I thought it might be the focus but that doesnt account for the input box not wanting to turn disabled either?

  4. #4
    rogerdavid is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3
    nevermind. Solved it. The stupid macro wizard tripped me up, I hadnt added an "else" clause. Def prefer writing my own :-|

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,467
    The posted code showed the else so couldn't have helped there.

    One way to open VBA editor: select [Event Procedure] in an event property, click the ellipses (...) to open VBA editor, type code.

    Still don't see how can disable a control that has the focus.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 6
    Last Post: 10-04-2012, 01:43 PM
  2. Replies: 2
    Last Post: 10-01-2012, 06:47 PM
  3. Replies: 4
    Last Post: 08-14-2012, 11:56 AM
  4. Replies: 1
    Last Post: 08-09-2012, 08:21 AM
  5. Enabled = "No" not working
    By jgelpi16 in forum Forms
    Replies: 3
    Last Post: 07-07-2011, 10:53 AM

Tags for this Thread

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