By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,552 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,552 IT Pros & Developers. It's quick & easy.

ComboBox has to be selected TWICE to generate data results on bound fields of labels

P: 2
Hello,
I have a two tables in my database (Customer, Transaction) which are related using the CustomerID. I have dragged and dropped the fields of Customer on my form using Visual Studio tools. When I select a different customer using the combo menu cboCustomer the fields of the Customer such as (name, last name, telephone) get updated. However, the fields related to the particular customer on the Transaction fields i.e. TransactionID, description etc are not.
Now, if I select the same customer TWICE, then the fields of Transaction are displayed.

What I'm I doing wrong?

Thanks!
Mar 7 '13 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,382
It would help to see the code.
Mar 7 '13 #2

P: 2
Hi Rabbit. I have dragged and dropped the controls from the data sources. This is what I have in the form load event and selected index change methodd of the cboCustomerName:


Expand|Select|Wrap|Line Numbers
  1.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.         'TODO: This line of code loads data into the 'DbPBDataSet.Customer' table. You can move, or remove it, as needed.
  3.         Me.CustomerTableAdapter.Fill(Me.DbPBDataSet.Customer)
  4.         'TODO: This line of code loads data into the 'DbPBDataSet.Employee' table. You can move, or remove it, as needed.
  5.         Me.EmployeeTableAdapter.Fill(Me.DbPBDataSet.Employee)
  6.  
  7.  
  8.         grpDealerSessions.Enabled = False
  9.         grpTables.Enabled = False
  10.         lblSessionIDRes.Text = "No Running Session"
  11.         'TODO: This line of code loads data into the 'DbPBDataSet.Session' table. You can move, or remove it, as needed.
  12.         Me.SessionTableAdapter.Fill(Me.DbPBDataSet.Session)
  13.  
  14.  
  15.         'TODO: This line of code loads data into the 'DbPBDataSet.DealerSessions' table. You can move, or remove it, as needed.
  16.         Me.DealerSessionsTableAdapter.Fill(Me.DbPBDataSet.DealerSessions)
  17.  
  18.  
  19.         'TODO: This line of code loads data into the 'DbPBDataSet.Game' table. You can move, or remove it, as needed.
  20.         Me.GameTableAdapter.Fill(Me.DbPBDataSet.Game)
  21.  
  22.         lblDateTime.Text = Now.ToString
  23.         'TODO: This line of code loads data into the 'DbPBDataSet.Transaction' table. You can move, or remove it, as needed.
  24.         ' Me.TransactionTableAdapter.Fill(Me.DbPBDataSet.Transaction)
  25.  
  26.  
  27.     End Sub
  28.  
  29. ----------------
  30.  
  31. Private Sub cboCustomerName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCustomerName.SelectedIndexChanged
  32.         Try
  33.  
  34.             Dim iCountBuyins, iSumBuyins, iSumCashouts, iBiggestWin, iBiggestLoss As Integer
  35.  
  36.             Thread.CurrentThread.CurrentCulture = New CultureInfo("el-GR", False)
  37.             Me.TransactionTableAdapter.FillByCustID(Me.DbPBDataSet.Transaction, CType(lblCustomerID.Text, Integer))
  38.  
  39.             iSumBuyins = CType(TransactionTableAdapter.scalarTotalBuyin(lblCustomerID.Text), Integer)
  40.             lblSumBuyins.Text = iSumBuyins
  41.  
  42.  
  43.             iCountBuyins = CType(TransactionTableAdapter.scalarCountbuyins(lblCustomerID.Text), Integer)
  44.             lblSumBuyins.Text = iCountBuyins
  45.  
  46.             iSumCashouts = CType(TransactionTableAdapter.scalarCashouts(lblCustomerID.Text), Integer)
  47.  
  48.             iBiggestWin = CType(TransactionTableAdapter.scalarBiggestwin(lblCustomerID.Text), Integer)
  49.             iBiggestLoss = CType(TransactionTableAdapter.scalarBiggestloss(lblCustomerID.Text), Integer)
  50.  
  51.             lblBiggestWinRes.Text = iBiggestWin.ToString("c")
  52.             lblBiggestLossRes.Text = iBiggestLoss.ToString("c")
  53.  
  54.  
  55.             ' Displays i formatted as currency for the CurrentCulture.
  56.             ' This will override any user settings and display the euro symbol.
  57.  
  58.             lblTotalRes.Text = (iSumCashouts - iSumBuyins).ToString("c")
  59.             ' FormatCurrency(iCashouts, , , TriState.True, )
  60.             Me.TransactionBindingSource.Position = Me.cboCustomerName.SelectedIndex
  61.         Catch ex As System.Exception
  62.             System.Windows.Forms.MessageBox.Show(ex.Message)
  63.         End Try
  64.     End Sub
Mar 7 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.