?
Solved

Updating Combo list after inserting new record

Posted on 2005-03-30
7
Medium Priority
?
240 Views
Last Modified: 2010-08-05
Hi,
I have a form that has a combo box who's list has Customers.  This is bound to a data adapter during form load.  The code is:

            daCustList.Fill(DataSet11)

I have a button that brings up a New Cutomer form that successfully adds a new Customer to the database.  No problem from a DB standpoint.

Once the new customer is added however, I need to refresh the Customer combo box list to show the newly added customer.  If I .Fill again, the list is appended to.

 I can't figure out how to do this, so help is appreciated.  I hope I'm using the DataAdapter & ComboBox correctly.

Regards,

Doug
0
Comment
Question by:dslocum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13664974
To refresh instead of append

daCustList.MissingSchemaAction = MissingSchemAction.AddWithKey
daCustList.AcceptChangesDuringFill = True
0
 
LVL 1

Author Comment

by:dslocum
ID: 13665108
BriCrowe,

Thanks. Your suggestion still doesn't cause my original ComboList to include the new Customer in the list, at least in my situation.  Is there another step I need to do after your code ?  

Thanks,

Doug
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13665177
you may need to rebind your combobox to the dataadapter
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:dslocum
ID: 13665583
BriCrowe,

Still having probs.  My code is:

    Private Sub btnCustNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustNew.Click
        Dim FrmCust As New frmCustomer

        Try
            With FrmCust

                .ShowDialog()      'Add new customer to DB

                daCustList.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey
                daCustList.AcceptChangesDuringFill = True
                cboCustName.Rebind()     'Added per your last suggestion

            End With

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

FYI, If I close the app and then reopen, the new Customer DOES show in the combo list.

BTW, I'm not sure if it matters, but I'm using a ComponentsOne Combo box.  I guess that this should work the same as a standard ComboBox.

I appreciate your help to hopeffuly resolve this!

Doug
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13665715
the lines...

daCustList.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey
daCustList.AcceptChangesDuringFill = True

only need to be declared once for the dataadapter so you can put them in your form.load procedure

to rebind try this...
cboCustName.databindings.remove(cboCustname.databindings("Text"))
cbocustname.databindings.add("Text", myDataSet.myDataTable, "ColumnName")

0
 
LVL 1

Author Comment

by:dslocum
ID: 13671065
Hello again,

I added a Watch to the C1 ComboBox, and it appears that there are no databindings, so the technique above isn't working.  When I stated my problem originally, I thought that the control was bound.  Is there some other .NET technique that is being used?

The design-time C1 control properties are set to:

DataSource = DataSet11
DataMember = ARCUSFIL_SQL    'This is the table with the appropriate SQL Select to fill the combo's list
DisplayMember = CustName
ValueMember = Cus_No

I don't necessarily expect that you know this C1 combo control, but can you recognize the technique that is used and continue to help with my goal?

Thanks for your time and patience.

Doug
0
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 1000 total points
ID: 13671262
everything looks the same as the standard combobox except for the DataMember property.  A standard  Combobox would look more like...

DataSource = DataSet11.tables("ARCUSFIL_SQL")
DisplayMember = "CustName"
ValueMember = "Cus_No"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question