Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with 2nd combo box (2000)

    Hello again guys ,

    Need your help again..

    I have attach 2 combo box on my usefrom to fill data in my work

    The problem is my 2nd combo boz didnt do what it suppossed to do like

    the 1st combo box did..

    Whats wrong with it ? Could you guys please help me again..thanks

    ps : plz refer to attachment

  2. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Posts
    3,788
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problem with 2nd combo box (2000)

    Delete the routine UserForm_Initialize2() and incorporate it into UserForm_Initialize()
    <pre>Private Sub UserForm_Initialize()

    With cboposition
    .AddItem "20"
    .AddItem "30"
    .AddItem "40"
    .AddItem "50"
    End With

    With cboposition2
    .AddItem "Exams 1"
    .AddItem "Exams 2"
    .AddItem "Exams 3"
    .AddItem "Exams 4"
    End With

    End Sub</pre>


  3. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    Thanks tony. it works like charm ..

  4. #4
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    ok..2 more thing before i forgot

    no 1 - Let say if i want to use the combo box and link it to some range let say

    the 1st combo box i want it to link with my range "pupils" that is a1:a4

    and so do the 2nd combo boz with my 2nd range "exams" b1:b4



    no 2 -Is it possible while on my userform , every time i want to go to the next

    combo box or text box , i simply can hit enter and it will go to the other box or

    combo box , because now , when i hit enter , it goes straight to the command button "OK"

    and not going to the next text box or combo box




    How do i do that..thanks again

  5. #5
    Platinum Lounger
    Join Date
    Jan 2001
    Posts
    3,788
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problem with 2nd combo box (2000)

    1/ With named ranges called Pupils & Exams, use the following code
    <pre>Private Sub UserForm_Initialize()
    Dim MyRange As Range, MyCell As Range
    Dim MyRange2 As Range, MyCell2 As Range

    Set MyRange = Range("Pupils")
    Set MyRange2 = Range("Exams")

    For Each MyCell In MyRange
    cboposition.AddItem MyCell.Value
    Next

    For Each MyCell2 In MyRange2
    cboposition2.AddItem MyCell2.Value
    Next

    End Sub</pre>


    2/ To set the tab order, select the form in the visual basic editor and choose "View>Tab Order" from the menus.

  6. #6
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    Thanks again tony for the prompt reply and it works with combo boxes and the range..

    But i can't find the tab order in the vba editor by by clicking properties of the user form.what i found is just tag and not tab..any idea ? thanks again

  7. #7
    Platinum Lounger
    Join Date
    Jan 2001
    Posts
    3,788
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problem with 2nd combo box (2000)

    1/ In the Forms section make sure the object is displayed rather than the code, then select "View>Tab Order" as per the image

  8. #8
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    thanks for the picture tony..it helps..my problem solved ..thanks to you tony..regards..

  9. #9
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    Hello again tony..

    I have try to populate range from your code..but it shows nothing....empty..

    i pull the range from other sheets..is that why it dont show the list..

    thanks..any idea ?

  10. #10
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    This is the code that i try to run..it works..but the list from the range dont show anything..

    When i select the combobox , its empty inside..




    Private Sub cmdCancel_Click()

    guru.Hide

    End Sub





    Private Sub cmdOK_Click()

    ActiveSheet.Unprotect Password:=""

    Range("d2").Value = cboposition6.Value
    Range("d3").Value = cboposition7.Value
    Range("t2").Value = cboposition8.Value
    Range("t3").Value = cboposition9.Value

    ActiveSheet.Protect Password:=""

    Unload guru

    End Sub











    Private Sub guru_Initialize()


    Dim MyRange6 As Range, MyCell6 As Range
    Dim MyRange7 As Range, MyCell7 As Range
    Dim MyRange8 As Range, MyCell8 As Range
    Dim MyRange9 As Range, MyCell9 As Range


    Set MyRange6 = Range("Teacher")
    Set MyRange7 = Range("Year")
    Set MyRange8 = Range("Total")
    Set MyRange9 = Range("Type")

    For Each MyCell6 In MyRange6
    cboposition6.AddItem MyCell6.Value
    Next

    For Each MyCell7 In MyRange7
    cboposition7.AddItem MyCell7.Value
    Next


    For Each MyCell8 In MyRange8
    cboposition8.AddItem MyCell8.Value
    Next

    For Each MyCell9 In MyRange9
    cboposition9.AddItem MyCell9.Value
    Next



    End Sub


    any comment..appreciated..thanks

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem with 2nd combo box (2000)

    Perhaps most of this can be done by setting the ControlSource property of the text boxes and combo boxes, and the RowSource property of the combo boxes. See attached version of the spreadsheet you posted earlier.

  12. #12
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    Thank hans..

    this is your statement : " Perhaps most of this can be done by setting the ControlSource property of the text boxes and combo boxes, and the RowSource property of the combo boxes."

    How do i do that ? thanks again

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem with 2nd combo box (2000)

    See the spreadsheet I attached to my previous reply, and the screenshot below. The ControlSource of one of the combo boxes has been set to a cell on GlobalKelas, and the RowSource to a named range.

    ControlSource is the cell that is populated with the item selected in the combo box.
    RowSource is the range that supplies the list items.

  14. #14
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    Hehe..thanks Hans..

    I think ..i'm getting understand a little bit about this..

    will try it first and then will make follow up if i want to know more ..thanks again

  15. #15
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with 2nd combo box (2000)

    At 1st this thing works smoothly..but when i go to 2nd combo box, try to fill data in cell d3..this error shows..what i

    have done wrong..please refer to attachment..thanks

Page 1 of 2 12 LastLast

Posting Permissions

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