• Problem with 2nd combo box (2000)

    • This topic has 32 replies, 3 voices, and was last updated 21 years ago.
    Author
    Topic
    #404966

    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

    Viewing 1 reply thread
    Author
    Replies
    • #827865

      Delete the routine UserForm_Initialize2() and incorporate it into UserForm_Initialize()

      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
      • #827867

        Thanks tony. it works like charm ..

        • #827873

          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

          • #827882

            1/ With named ranges called Pupils & Exams, use the following code

            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

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

            • #827900

              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

            • #827904

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

            • #827906

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

            • #827907

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

            • #827905

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

            • #829261

              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 ?

            • #829263

              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

            • #829284

              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.

            • #829304

              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

            • #829305

              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

            • #829317

              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.

            • #829330

              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

            • #829504

              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

            • #829506

              This is the file that i got the error after using hans method..thanks..

            • #829556

              I think i found the solution……

              My mistake..hehe…sorry guys..thanks a zillion

            • #829557

              I think i found the solution……

              My mistake..hehe…sorry guys..thanks a zillion

            • #829507

              This is the file that i got the error after using hans method..thanks..

            • #829505

              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

            • #829331

              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

            • #829318

              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.

            • #829285

              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.

            • #829264

              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

            • #829262

              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 ?

            • #827901

              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

          • #827883

            1/ With named ranges called Pupils & Exams, use the following code

            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

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

        • #827877

          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

      • #827868

        Thanks tony. it works like charm ..

    • #827866

      Delete the routine UserForm_Initialize2() and incorporate it into UserForm_Initialize()

      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
    Viewing 1 reply thread
    Reply To: Problem with 2nd combo box (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: