I have a combobox that is bound to a DB and works great. However, when the user adds a value to the table to which the combobox is bound, the combobox keeps the old value and adds the current items in the table. In this case the table originally held just one record ("2012"). The user added 2013 so the table now shows two records ("2012" and "2013"), but the combobox shows three records ("2012", "2012", and "2013"). UNTIL I exit the app and restart, in which case it correctly reflects the only two records in the table ("2012" and "2013"). I have tried cboYear.Datasource = Nothing, cboYear.items.clear, cboYear.DataBindings.clear and nothing works. Here is the code.

Try
            Dim asql As String = ("SELECT * FROM YearsAvailable ORDER BY CurrentYear")
            Dim da As New OleDbDataAdapter(asql, con)
            da.Fill(ds)

            cboYear.ValueMember = "CurrentYear"
            cboYear.DataSource = ds.Tables(0)
            cboYear.SelectedIndex = 0
            CurrentYear = cboYear.Text
            Me.Text = "MSD of Perry Township Compensation Model: " & CurrentYear

            'cboYear.Refresh()

        Catch ex As Exception
            MsgBox("ERROR filling the YEAR control: " & ex.Message.ToString)
        End Try

I tested your code and it was right. But, somehow, your ds did not change during run time and it makes your combobox couldn't change, too.
My recommendation: Place your combobox loading sub on some where it continually checking SQL and update a new dataset when your SQL table change.
Hope this help.

ds.clear did the trick. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.