Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43

    field enabling and disabling

    I have a form with two fields and a command button i want to be disabled unless certain criteria are met.

    First field: Is_hold_tag_required - this is a yes or no field
    Second field: responsible_qe - this is a combo box


    Command button: prints a report
    Not sure if this matters but the form is a tab form. All fields are on the same tab

    Is_hold_tag_required is enabled by default. The responsible_qe field is disabled by default unless the is_hold_tag_required is clicked yes. The command button is disabled by default until a selection is made for responsible_qe.

    The problem I am having is that this works intermittently. Sometimes I have to click yes on the is_hold_tag_required field and then re-select a name in the responsible_qe field and after doing that the command button will be enabled again.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Which events are you using to enable/disable things. I presume you're working with vba


    Sent from my iPhone using Tapatalk

  3. #3
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    I am using the on change event

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Is hold_tag_required a field in a table?


    Sent from my iPhone using Tapatalk

  5. #5
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    Yes as is responsible_qe

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    What code are you using behind the on change event


    Sent from my iPhone using Tapatalk

  7. #7
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    Private Sub Is_Hold_Tag_Required_AfterUpdate()
    If Is_Hold_Tag_Required = "Yes" Then
    Responsible_QE.Enabled = True
    Else
    Responsible_QE.Enabled = False


    End If


    End Sub

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    field enabling and disabling

    I had it on the on change event and it worked fine

    And I'm not sure if it's relevant but I had me.responsible_qe and the other controls in the code


    Sent from my iPad using Tapatalk

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by koncreat View Post

    ...The problem I am having is that this works intermittently...
    If the 'working intermittently' involves moving from Record to Record, it's because you also need the same code in the Form_Current event. As you move from Record to Record, this will insure that the status of the button depends on conditions in the current Record, not conditions in the last Record that was entered/edited.

    Linq ;0)>

  10. #10
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    The Form_Current worked for the the responsible_qe field. I also need to have the command button the prints the report to enabled only if responsible_qe has been selected. It currently works intermittently as described previously I'm just not sure how to code the two statements. This is what I currently have:

    Private Sub Form_Current()
    If Is_Hold_Tag_Required = "Yes" Then
    Responsible_QE.Enabled = True
    Else
    Responsible_QE.Enabled = False








    If Responsible_QE.enabled = "Yes" Then
    Command330.Enabled = True
    Else
    Command330.Enabled = False




    End If


    End If




    End Sub

  11. #11
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    If Responsible_QE = "Yes" Then
     Command330.Enabled = True
     Else
     Command330.Enabled = False
    would it be feasible to add this elsewhere, say on the ONchange event of the combobox

    That way you're dealing with one issue at a time

    I'd also add

    command330.enabled = false to the Form_open event so it resets properly

  12. #12
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    If i add it to the on change event and go to the next record then it will be disabled and the user has to re-select a value in the responsible qe field to make it the command button active again

  13. #13
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    If Is_Hold_Tag_Required = "Yes" Then
     Responsible_QE.Enabled = True
     Else
     Command330.Enabled = False
    end if
    
    
    
     
    If Responsible_qe.enabled = true and responsible_qe ="YES" Then
     Command330.Enabled = True
     Else
     Command330.Enabled = False
     End If
    This should do it I think

  14. #14
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    Here is what I have and i get a debug error:

    Private Sub Form_Current()
    If Is_Hold_Tag_Required = "Yes" Then
    Responsible_QE.Enabled = True
    Else
    Responsible_QE.Enabled = False
    End If


    If Responsible_QE.ListIndex < 0 And Is_Hold_Tag_Required.Enabled = "Yes" Then
    Command330.Enabled = True
    Else
    Command330.Enabled = False




    End If




    End Sub

  15. #15
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    Private Sub Form_Current()
     If Is_Hold_Tag_Required = "Yes" Then
     Responsible_QE.Enabled = True
    If Responsible_QE.ListIndex < 0  Then
     Command330.Enabled = True
     Else
     Command330.Enabled = False
    
    End If
    
    Else
     Responsible_QE.Enabled = False
     End If
    
    End Sub

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Enabling and Disabling Buttons on a Form.
    By Slurry Pumper in forum Forms
    Replies: 10
    Last Post: 11-14-2016, 10:07 AM
  2. Replies: 4
    Last Post: 10-25-2013, 06:48 AM
  3. Enabling and disabling fields
    By SgtSaunders69 in forum Programming
    Replies: 9
    Last Post: 12-27-2011, 06:11 PM
  4. Disabling and Enabling subforms
    By vt800c in forum Programming
    Replies: 3
    Last Post: 05-24-2011, 07:37 AM
  5. Enabling Disabling Combo Boxes from Values
    By vdanelia in forum Forms
    Replies: 3
    Last Post: 02-04-2011, 10: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