Results 1 to 7 of 7

Thread: [RESOLVED] One combo box isn’t behaving itself

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    Townsville, Qld, Australia
    Posts
    135

    Resolved [RESOLVED] One combo box isn’t behaving itself

    I’ve got a problem with a user form which has two radio buttons and two combo boxes. The rowsource depends upon which radio button the user clicks. (See attached file.)

    The user chooses a radio button and can then select a value in either combo box. The other combo box then picks up the appropriate value & a description appears in the label.

    The problem comes in when the user decides that they’re looking in the wrong place & they click the other radio button. The combo box called cmb_name picks up the first value in the list it has just been using as a rowsource. When the user clicks on it to get the drop-down list, the correct values are there.

    The other combo-box (cmb_prn) is behaving itself properly. I suspect I’m missing something really simple but it is annoying me. I would appreciate help with this.
    Thank you

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    Townsville, Qld, Australia
    Posts
    135

    Re: One combo box isn’t behaving itself

    Oops! I don't appear to have succeeded in uploading the file!

    Ah, well, here is the code instead:

    HTML Code:
    Dim row_number As Integer
    Dim the_row As Integer
    Dim Range3P As Range
    Dim RangeOP As Range
    Dim Range3N As Range
    Dim RangeON As Range
    Dim t As Integer
    Dim s As Integer
    
    Private Sub UserForm_Click()
    
    End Sub
     
    Private Sub cmb_prn_Change()
    Call Show_by_PRN
    End Sub
     
    Private Sub cmd_cancel_Click()
    UserForm1.Hide
    Unload UserForm1
    End Sub
     
    Private Sub opt_other_Click()
     
    If opt_other = True Then
    opt_ts = False
    End If
     
    cmb_name = ""
    cmb_name.RowSource = vbNullString
    cmb_prn.RowSource = vbNullString
    cmb_prn = ""
    lbl_acty_descrip.Caption = ""
     
    If opt_other = True Then
    Call FindInOther
    End If
    End Sub
     
    Private Sub opt_ts_Click()
     
    If opt_ts = True Then
    opt_other = False
    End If
     
    'cmb_name_search.Clear
    cmb_name = ""
    cmb_name.RowSource = vbNullString
    cmb_prn.RowSource = vbNullString
    cmb_prn = ""
    lbl_acty_descrip.Caption = ""
     
    If opt_ts = True Then
    Call FindInTS
    End If
    End Sub
     
    Private Sub UserForm_Initialize()
     
    With UserForm1
    ShowModal = False
    End With
    opt_ts = True
     
    End Sub
     
    Private Sub cmb_name_Click()
    Call Show_by_name
    End Sub
     
    Sub Show_by_name()
    If cmb_name.ListCount = 0 Then
    row_number = 0
    Else
    row_number = cmb_name.ListIndex
    End If
    s = row_number + 5
    Cells(s, 2).Activate
    cmb_prn = Cells(s, 2).Text
    lbl_acty_descrip.Caption = Cells(s, 9).Text
     
    End Sub
     
    Sub Show_by_PRN()
    If cmb_prn.ListCount = 0 Then
    the_row = 0
    Else
    the_row = cmb_prn.ListIndex
    End If
    t = the_row + 5
    Cells(t, 2).Activate
    cmb_name = Cells(t, 5).Text
    lbl_acty_descrip.Caption = Cells(t, 9).Text
    End Sub
     
    Sub FindInTS()
     
    Sheets("ts").Select
    Cells(5, 5).Select
      
    cmb_prn.RowSource = "B5: B10"
    cmb_name.RowSource = "E5: E10"
    
    Sheets("ts").Activate
     
    End Sub
     
    Sub FindInOther()
     
    Sheets("other").Select
    Cells(5, 5).Select
       
    cmb_prn.RowSource = "B5:B10"
    cmb_name.RowSource = "E5:E10"
    Sheets("other").Activate
     
    End Sub
    (The data source is on two sheets of an Excel workbook, in columns B & E.)

  3. #3
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: One combo box isn’t behaving itself

    Oops! I don't appear to have succeeded in uploading the file!
    u can attach file as zip or rar format.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    Townsville, Qld, Australia
    Posts
    135

    Re: One combo box isn’t behaving itself

    Try this.
    Attached Files Attached Files

  5. #5
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: One combo box isn’t behaving itself

    as i found one thing is
    Code:
    Private Sub cmb_prn_Change()
    Call Show_by_PRN
    End Sub
    in change event, other one is in click event
    Code:
    Private Sub cmb_name_Click()
    Call Show_by_name
    End Sub
    so change the change event to click event
    edited: i m not sure that this is ur issue.
    Last edited by seenu_1st; Aug 1st, 2011 at 06:50 AM.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    Townsville, Qld, Australia
    Posts
    135

    Re: One combo box isn’t behaving itself

    Yes, using a "click" event with both combo-boxes solves the problem. Thank you for spotting that.

  7. #7
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: [RESOLVED] One combo box isn’t behaving itself

    oh! that's good to knw...
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


Posting Permissions

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



Click Here to Expand Forum to Full Width