none
combobox value enabling or disabling textbox RRS feed

  • Question

  • Hi, 

    i currently have a combo box with a 2 values in it - "Classroom" and "Non-Classroom".

    i also have a textbox which is disabled by default.

    What i want to do is whenever the user select Classroom , the textbox will be enabled and when the user select Non-classroom, the textbox will be disabled. 

    this is my current codes.

    Option Compare Database
    
    Private Sub ComboBox1_SelectedIndexChanged()
            If Me.comboTEST.Selected = True Then
                Me.textboxTEST.Enabled = True
            Else
                Me.textboxTEST.Enabled = False
            End If
     
        End Sub
    
    thanks

    Wednesday, May 16, 2018 7:58 AM

Answers

  • Hi syahid Noor,

    use the "AfterUpdate" Event:

    Private Sub ComboBox1_AfterUpdate()
        If Me.ComboBox1 = "Classroom" Then
            Me.textboxTEST.Enabled = True
        Else
            Me.textboxTEST.Enabled = False
        End If
    End Sub
    regards Volker

    • Proposed as answer by Volker Salzinger Wednesday, May 16, 2018 9:24 AM
    • Marked as answer by syahid noor Wednesday, May 16, 2018 11:53 PM
    Wednesday, May 16, 2018 8:24 AM

All replies

  • Hi syahid Noor,

    use the "AfterUpdate" Event:

    Private Sub ComboBox1_AfterUpdate()
        If Me.ComboBox1 = "Classroom" Then
            Me.textboxTEST.Enabled = True
        Else
            Me.textboxTEST.Enabled = False
        End If
    End Sub
    regards Volker

    • Proposed as answer by Volker Salzinger Wednesday, May 16, 2018 9:24 AM
    • Marked as answer by syahid noor Wednesday, May 16, 2018 11:53 PM
    Wednesday, May 16, 2018 8:24 AM
  • Hi Volker,

    It works! Thanks!

    Wednesday, May 16, 2018 8:48 AM