Consulting

Results 1 to 4 of 4

Thread: Solved: enable or disable comboboxes based on textbox enter

  1. #1
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location

    Solved: enable or disable comboboxes based on textbox enter

    Hi
    First of all, this is a crosspost
    http://www.ozgrid.com/forum/showthread.php?t=168597
    And I am very sorry for that.
    But I really need an urgent help in this and I didnt get any suggestions lately in that forum.

    Here's my issue:
    Hi
    I'm have a form1 with several textboxes (textbox1, textbox2,...) and another form2 with comboboxes (combobox1, combobox2,...).
    What I'm trying to do is:
    Click in textbox1, open form2, enable combobox1, disable or lock other comboboxes
    Click in textbox2, open form2, enable combobox2, disable or lock other comboboxes
    and so on...

    The code below works if I set it for just one combo in the change event. If I set for every combo, it locks all combos in form2

    [VBA]Private Sub ComboBox1_Change()
    If Me.ComboBox1.ListIndex > -1 Then
    Me.ComboBox2.Enabled = False
    Me.ComboBox3.Enabled = False
    End If
    End Sub[/VBA]

    How do I change code to work as I want?

    Once again I apologize for this crosspost
    Thank you very much in advance
    Ioncila

  2. #2
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    Ioncila,
    Not quite sure what you are trying to accomplish... from your write up, it seems like you have 2 userforms, one with text boxes and one with combo boxes. You want the user to click on a text box and show userform2 with locks on specific comboboxes within that userform. Is this correct? If so, why not use a command button instead of an on click event with a text box?
    In your code, however, you show a combobox1 change event. This has nothing to do with another userform's text box event.

    Please clarify.

    Thanks,

    CodeNinja

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by ioncila
    Hi
    First of all, this is a crosspost
    http://www.ozgrid.com/forum/showthread.php?t=168597
    And I am very sorry for that.
    But I really need an urgent help in this and I didnt get any suggestions lately in that forum.
    Learn from that mistake

    [VBA]Private Sub TextBox1_Enter()

    With UserForm2

    .ComboBox1.Enabled = True
    .ComboBox2.Enabled = False
    .ComboBox3.Enabled = False
    'etc.

    .Show
    End With
    End Sub

    Private Sub TextBox2_Enter()

    With UserForm2

    .ComboBox1.Enabled = False
    .ComboBox2.Enabled = True
    .ComboBox3.Enabled = False
    'etc.

    .Show
    End With
    End Sub

    'etc.[/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location
    Quote Originally Posted by xld
    Learn from that mistake
    Got the message

    It's the perfect solution .
    Thank you very much.
    Ioncila

    @codeninja: thanks for your reply too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •