multiple values in previous comboboxes VB.net-VBForums
Results 1 to 4 of 4

Thread: multiple values in previous comboboxes VB.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    7

    Question multiple values in previous comboboxes VB.net

    Hi All,

    On my form, I have few comboboxes, which are taking data from access table.
    Name:  Combo.jpg
Views: 1257
Size:  43.3 KB

    The form works like that -

    On-Load connection.Open()

    after that, user is oblige to choose

    1) Account, if he will choose value from combobox, Tower combobox will be enabled (true)

    2) Tower, if he will choose value from combobox, Process combobox will be enabled (true)

    3) Process, if he will choose value from combobox, User combobox will be enabled (true)

    4) rest of comboboxes will be enabled after choosing User. (Those are depends on the user and earlier comboboxes)

    My problem is, that Combobox is taking data from table in Access, each has it's own table, because we are uploading data from other form, and our processes are sufisticated, and after choosing first, second, thirds etc. - everything is okay, when employees are choosing it correctly, but if he will choose wrong value, and he would like to change it in previous combobox, the values in it are:

    Name:  Comboissue.jpg
Views: 1470
Size:  45.1 KB

    There are only multiple items, and I cannot clear previous items and start once again....

    The code for User combobox (as an example). I'm calling it from Form_Load.

    Code:
        Sub fillUser()
            Dim var As String = cbAccount.SelectedItem
            Dim var2 As String = cbTower.SelectedItem
            Dim var3 As String = cbProcess.SelectedItem
            strsql = "Select Distinct * from TimerUser where((TimerAccount like '%" + var + "%') AND (TimerTower like '%" + var2 + "%') and (TimerProcess like '%" + var3 + "%'))"
            Dim acscmd As New OleDb.OleDbCommand
            acscmd.CommandText = strsql
            acscmd.Connection = cn
            acsdr = acscmd.ExecuteReader
            While (acsdr.Read())
                Me.cbUser.Items.Add(acsdr("UserT"))
    
            End While
            acscmd.Dispose()
            acsdr.Close()
        End Sub
    Thank you for your help in advance!

    Matt

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,113

    Re: multiple values in previous comboboxes VB.net

    From what you describe, each combobox is inherently dependent on selections made previously. So, it could appear that there are a series of steps that the user must take, with each step being a combobox. That's a bit unfortunate. If the user makes a mistake on Step 1, and doesn't realize it until Step 4, the only option is to take them all the way back to Step 1, which means that they have to repeat steps 2 and 3. Fortunately, there are not all that many steps.

    One thing I would suggest is that you don't worry about which step caused a problem. If it wasn't the most recent step, you might as well start from the beginning. After all, a CLEAR button is going to be pretty easy and obvious for the user. The alternative is putting a clear button beside each combobox, or doing essentially that in code. After all, once the user has moved on to step X, then any mistake made previously will have to clear X, and all intervening steps. If that isn't necessary, then the steps themselves are not necessary and the whole design is flawed. If that is necessary, then you might consider a clear button beside each one, because the actions taken will be to not just re-set the current combobox, but all subsequent comboboxes. Having a button event in which to do this would be nice. If you were to try to do that by interpreting the meaning of the SelectedItem Changed event of the combobox, then you'd have to be able to tell when the user changed it the first time, versus when they user fixes a mistake they made. That could be tricky.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    7

    Re: multiple values in previous comboboxes VB.net

    Thnak you for the solution. I've done the amendments, but unfortunately, items.clear() is not working properly. I've tried selectedindex = -1 as well, but it's clearing the choosen item only, but the "dropdown" items are still in the combobox. Even after combobox.refresh duplicate/multi values are in the combobox...

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,113

    Re: multiple values in previous comboboxes VB.net

    Something is clearly wrong with populating the combobox. If the snippet you posted is an example of how you fill all the comboboxes, you should have a relatively easy time tracking this down, because you could take the SQL and run it in a query editor to see what it was returning. It looks pretty straightforward, though, so perhaps that's not how you filled the other comboboxes.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.