locked
Toggle Button to disable subforms and current form controls RRS feed

  • Question

  • Hello all,

    I currently have a toggle button on an access form that when clicked grays out the controls on the form. I now need to add a subform which I will also need to be disabled once the toggle button is selected. I have added the subform into the VBA and it does become disabled however it does not become Gray as the other objects. How can I carry out the action to move through to the subform? Attached you will find screen shots of both states and also attached is the vba code for the event.

    dbo_SRT is the subform.

    The first image shows the controls enabled. The second image shows the controls disabled. The subform is the SRT-#### field.

    Please let me know your suggestions. Thanks.

    Not DisabledDisabled

    Option Compare Database
    
    Private Sub Form_Load()
    Call ControlsEnable
    End Sub
    
    
    Private Sub Form_Current()
    Call ControlsEnable
    End Sub
    
    
    Private Sub Toggle54_Click()
    Me.ClosedBy = Environ("UserName")
    Call ControlsEnable
    End Sub
    
    Private Sub ControlsEnable()
    Dim binEnable As Boolean
    
    If Me.Toggle54.Value = -1 And Nz(Me.ActionStatus, 0) = -1 Then
        binEnable = False
        Else
        binEnable = True
        End If
        Me.COST.Enabled = binEnable
        Me.RootCause.Enabled = binEnable
        Me.EstTime.Enabled = binEnable
        Me.Option50.Enabled = binEnable
        Me.Option52.Enabled = binEnable
        Me.IRSentDate.Enabled = binEnable
        Me.dbo_SRT.Enabled = binEnable
    End Sub
    


    Keith

    Monday, December 23, 2013 8:39 PM

Answers

  • When you disable subform, controls is not greyed, you must enable/disable controls on form, example:

    Me.dbo_SRT.Form.Controls("textBoxNameOnSubform").Enabled = binEnable



    Michał


    • Edited by Dziubek Michał Monday, December 23, 2013 10:32 PM
    • Proposed as answer by Van Dinh Monday, December 23, 2013 11:41 PM
    • Marked as answer by Keith732 Friday, December 27, 2013 9:01 PM
    Monday, December 23, 2013 9:55 PM

All replies

  • When you disable subform, controls is not greyed, you must enable/disable controls on form, example:

    Me.dbo_SRT.Form.Controls("textBoxNameOnSubform").Enabled = binEnable



    Michał


    • Edited by Dziubek Michał Monday, December 23, 2013 10:32 PM
    • Proposed as answer by Van Dinh Monday, December 23, 2013 11:41 PM
    • Marked as answer by Keith732 Friday, December 27, 2013 9:01 PM
    Monday, December 23, 2013 9:55 PM
  • Thanks for your help! Right on the money.

    Keith

    Friday, December 27, 2013 9:01 PM